import * as THREE from "three";

// 科技感地球
class technologyEarth {
  constructor(e, n) {
    this.earthGroup = n.earthGroup
    this.config = {
      defaultConfig: {
        pointImage: "dot.png",
        borderImage: "opacityMap.png",
        mapImage: "map_inverted3.jpg"
      },
      pointConfig: {
        color: "#3c5e7c",
        size: 22,
        count: 200
      },
      lineConfig: {
        show: true,
        color: "#5e8db6",
        opacity: 1
      }
    }
    this.showGroup = new THREE.Group()
    this.textureLoader = new THREE.TextureLoader
    this.earthGroup.add(this.showGroup)
    this.height = n.height
    this.devicePixelRatio = n.devicePixelRatio ? n.devicePixelRatio : 1
    this.vertexShader = `
      uniform float size;
      uniform float scale;
      varying float opacity;
      void main() {
        vec4 mPosition = modelMatrix * vec4( position, 1.0 );
        vec4 mvPosition = viewMatrix * mPosition;
        vec4 mZeroPositon = modelMatrix * vec4(.0, .0, .0, 1.0);
        vec3 positionToZero = mPosition.xyz - mZeroPositon.xyz;
        vec3 vToEye = cameraPosition - mPosition.xyz;
        opacity = dot(vToEye, positionToZero);
        gl_PointSize = size * ( scale / -mvPosition.z );
        gl_Position = projectionMatrix * mvPosition;
      }
    `
    this.fragmentShader = `
      uniform vec3 color;
      uniform sampler2D pointTexture;
      varying float opacity;
      void main() {
        if(opacity <= 0.0) {
          gl_FragColor = vec4(color, 0.05);
        } else {
          gl_FragColor = vec4(color, 1.0);
        }
        gl_FragColor = gl_FragColor * texture2D( pointTexture, gl_PointCoord );
      }
    `
    this.initPointsMaterial()
    this.showPoints()
    if (this.config.lineConfig.show) {
      this.initBorderMaterial()
      this.showBorder()
    }
    return this
  }
  showPoints() {
    var image = document.createElement("img")
    image.setAttribute("crossOrigin", "anonymous")
    image.src = this.config.defaultConfig.mapImage
    image.onload = function () {
      var canvas = document.createElement("canvas")
      var ctx = canvas.getContext("2d");
      canvas.width = image.width
      canvas.height = image.height
      ctx.drawImage(image, 0, 0, image.width, image.height)
      this.earthImgData = ctx.getImageData(0, 0, image.width, image.height)
      this.createEarthParticles(this.earthImgData, image.width, image.height)
    }
  }
  showBorder() {
    this.border = new THREE.Mesh(new THREE.SphereBufferGeometry(1e3, 128, 128), this.borderMaterial)
    this.showGroup.add(this.border)
  }
  initPointsMaterial() {
    this.pointsMaterial = new THREE.ShaderMaterial({
      uniforms: {
        scale: {
          value: this.height / 2 * this.devicePixelRatio
        },
        color: {
          value: new THREE.Color(this.config.pointConfig.color.toLocaleLowerCase())
        },
        pointTexture: {
          value: this.textureLoader.load(this.config.defaultConfig.pointImage)
        },
        size: {
          value: this.config.pointConfig.size
        },
        radius: {
          value: 1e3
        }
      },
      transparent: true,
      depthTest: false,
      blending: THREE.AdditiveBlending,
      vertexShader: this.vertexShader,
      fragmentShader: this.fragmentShader,
      alphaTest: 0.8
    })
  }
  initBorderMaterial() {
    this.borderMaterial = new THREE.MeshBasicMaterial({
      color: new THREE.Color(this.config.lineConfig.color.toLocaleLowerCase()),
      map: this.textureLoader.load(this.config.defaultConfig.borderImage),
      transparent: true,
      blending: THREE.AdditiveBlending,
      depthTest: false,
      opacity: this.config.lineConfig.opacity
    })
  }
  createEarthParticles(e, t, a) {
    var i = []
    var r = new THREE.Spherical()
    r.radius = 1e3
    var o = this.config.pointConfig.count
    for (var s = 0; s < o; s++) {
      var l = new THREE.Vector3()
      var u = 1 / Math.cos(Math.abs(s - o / 2) / o * Math.PI)
      for (var c = 0; c < o; c += u) {
        var h = c / o
        var p = s / o
        Math.floor(2 * Math.random());
        if (this.isLandByUV(h, p, e, t, a)) {
          r.theta = h * Math.PI * 2 - Math.PI / 2
          r.phi = p * Math.PI
          l.setFromSpherical(r)
          i.push(l.x, l.y, l.z)
        }
      }
      l = null
    }
    var d = new THREE.BufferGeometry;
    d.addAttribute("position", new THREE.Float32BufferAttribute(i, 3))
    d.computeBoundingSphere()
    this.points = new THREE.Points(d, this.pointsMaterial)
    this.points.renderOrder = 3
    this.showGroup.add(this.points)
    i = null
  }
  isLandByUV(e, t, a, n, i) {
    if (!a) {
      console.error("data error!")
    }
    var r = parseInt(n * e)
    var o = parseInt(i * t)
    return 100 < a.data[4 * (o * a.width + r)]
  }
  updateComponent(e) {
    var a = this.config.pointConfig
    var n = this.config.lineConfig
    this.config = e.configuration.technologyEarth
    var r = this.config.pointConfig
    var o = this.config.lineConfig
    if (!(r.size === a.size && r.color === a.color)) {
      this.pointsMaterial.uniforms.size.value = r.size
      this.pointsMaterial.uniforms.color.value = new b.Color(r.color)
    }
    if (!(o.color === n.color && o.opacity === n.opacity)) {
      this.borderMaterial.color = new b.Color(o.color)
      this.borderMaterial.opacity = o.opacity
    }
    if (r.count !== a.count) {
      this.points && this.points.geometry && this.points.geometry.dispose()
      this.showGroup.remove(this.points)
      this.points = null
      this.showPoints()
    }
    if (o.show !== n.show) {
      this.destroyBorder()
      if (o.show) {
        this.initBorderMaterial()
        this.showBorder()
      }
    }
  }
  destroyPoints() {
    this.points && this.points.geometry && this.points.geometry.dispose()
    this.pointsMaterial && this.pointsMaterial.map && this.pointsMaterial.map.dispose()
    this.pointsMaterial && this.pointsMaterial.dispose()
    this.showGroup.remove(this.points)
    this.pointsMaterial && (this.pointsMaterial.map = null)
    this.pointsMaterial = null
    this.points = null
  }
  destroyBorder() {
    this.border && this.border.geometry && this.border.geometry.dispose()
    this.borderMaterial && this.borderMaterial.map && this.borderMaterial.map.dispose()
    this.borderMaterial && this.borderMaterial.dispose()
    this.showGroup.remove(this.border)
    this.borderMaterial && (this.borderMaterial.map = null)
    this.borderMaterial = null
    this.border = null
  }
  destroy() {
    this.textureLoader = null
    this.earthImgData = null
    this.destroyPoints()
    this.destroyBorder()
    this.earthGroup.remove(this.showGroup)
    this.showGroup = null
  }
}

// 大气层
class Atmosphere {
  constructor(e, n) {
    this.config = e.configuration.Atmosphere
    this.otherGroup = n.otherGroup
    this.showGroup = new THREE.Group()
    this.otherGroup.add(this.showGroup)
    this.inRadius = 1e3 + this.config.baseConfig.height
    this.initMaterial()
    this.showData()
    return this
  }
  initMaterial() {
    var e = ["varying vec3 vVertexWorldPosition;", "varying vec3 vVertexNormal;", "varying vec4 vFragColor;", "void main(){", " vVertexNormal = normalize(normalMatrix * normal);", " vVertexWorldPosition  = (modelMatrix * vec4(position, 1.0)).xyz;", " // set gl_Position", " gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);", "}"].join("\n")
    var t = ["uniform vec3 glowColor;", "uniform float  opacity;", "uniform float  division;", "uniform float  coeficient;", "uniform float  power;", "uniform float  scale;", "varying vec3 vVertexNormal;", "varying vec3 vVertexWorldPosition;", "varying vec4 vFragColor;", "void main(){", " vec3 worldVertexToCamera= cameraPosition - vVertexWorldPosition;", " vec3 viewCameraToVertex = (viewMatrix * vec4(worldVertexToCamera, 0.0)).xyz;", " viewCameraToVertex  = normalize(viewCameraToVertex);", " float intensity   = coeficient + dot(vVertexNormal, viewCameraToVertex);", " if(intensity > division){ discard;}", " intensity = intensity / division * scale;", " intensity = pow(intensity, power);", " gl_FragColor = vec4(glowColor, opacity*intensity);", "}"].join("\n")
    var a = (new THREE.Color).setStyle(this.config.baseConfig.color.toLocaleLowerCase())
    var n = Object(T.rgb)(this.config.baseConfig.color).opacity;
    this.material_glow_out = new b.ShaderMaterial({
      uniforms: {
        division: {
          type: "f",
          value: Math.sqrt(this.inRadius * this.inRadius - 1e6) / this.inRadius
        },
        coeficient: {
          type: "f",
          value: -1e-4
        },
        power: {
          type: "f",
          value: 5
        },
        scale: {
          type: "f",
          value: .85
        },
        glowColor: {
          type: "c",
          value: a
        },
        opacity: {
          type: "f",
          value: n
        }
      },
      vertexShader: e,
      fragmentShader: t,
      blending: THREE.NormalBlending,
      transparent: !0,
      depthWrite: !1
    })
    this.material_glow = new THREE.ShaderMaterial({
      uniforms: {
        division: {
          type: "f",
          value: Math.sqrt(this.inRadius * this.inRadius - 1e6) / this.inRadius
        },
        coeficient: {
          type: "f",
          value: -1e-4
        },
        power: {
          type: "f",
          value: 25
        },
        scale: {
          type: "f",
          value: 1
        },
        glowColor: {
          type: "c",
          value: a
        },
        opacity: {
          type: "f",
          value: n
        }
      },
      vertexShader: e,
      fragmentShader: t,
      blending: THREE.NormalBlending,
      transparent: !0,
      depthWrite: !1
    })
  }
  showData() {
    var e = new b.SphereBufferGeometry(this.inRadius, 64, 64)
    var t = new b.Mesh(e, this.material_glow_out);
    this.showGroup.add(t);
    var a = new b.Mesh(e, this.material_glow);
    this.showGroup.add(a)
  }
  updateComponent(e) {
    var t = this.config;
    this.config = e.configuration.Atmosphere
    if (t.baseConfig.height !== this.config.baseConfig.height) {
      this.inRadius = 1e3 + this.config.baseConfig.height
      this.clearAll()
      this.initMaterial()
      this.showData()
    } else if (t.baseConfig.color !== this.config.baseConfig.color) {
      var a = (new b.Color).setStyle(this.config.baseConfig.color.toLocaleLowerCase());
      if (this.material_glow_out) {
        this.material_glow_out.uniforms.glowColor.value = a
        this.material_glow_out.uniforms.opacity.value = Object(T.rgb)(this.config.baseConfig.color).opacity
      }
      if (this.material_glow) {
        this.material_glow.uniforms.glowColor.value = a
        this.material_glow_out.uniforms.opacity.value = Object(T.rgb)(this.config.baseConfig.color).opacity
      }
    }
  }
  clearAll() {
    this.destroy()
    this.showGroup = new THREE.Group()
    this.otherGroup.add(this.showGroup)
  }
  destroy() {
    this.otherGroup.remove(this.showGroup)
    Object(S.deepDispose)(this.showGroup)
    this.showGroup = null
    this.material_glow_out = null
    this.material_glow = null
  }
}

// 大气层内
class AtmosphereInner {
  constructor(e, n) {
    this.config = e.configuration.AtmosphereInner
    this.otherGroup = n.otherGroup
    this.showGroup = new THREE.Group()
    this.otherGroup.add(this.showGroup)
    this.inRadius = 1e3 + this.config.baseConfig.height
    this.initMaterial()
    this.showData()
  }
  initMaterial() {
    var e = ["varying vec3 vVertexWorldPosition;", "varying vec3 vVertexNormal;", "varying vec4 vFragColor;", "void main(){", " vVertexNormal = normalize(normalMatrix * normal);", " vVertexWorldPosition  = (modelMatrix * vec4(position, 1.0)).xyz;", " // set gl_Position", " gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);", "}"].join("\n")
    var t = ["uniform vec3 glowColor;", "uniform float  division;", "uniform float  coeficient;", "uniform float  opacity;", "uniform float  power;", "uniform float  scale;", "varying vec3 vVertexNormal;", "varying vec3 vVertexWorldPosition;", "varying vec4 vFragColor;", "void main(){", " vec3 worldVertexToCamera= cameraPosition - vVertexWorldPosition;", " vec3 viewCameraToVertex = (viewMatrix * vec4(worldVertexToCamera, 0.0)).xyz;", " viewCameraToVertex  = normalize(viewCameraToVertex);", " float intensity   = coeficient + dot(vVertexNormal, viewCameraToVertex);", " if(intensity < division){ discard;}", " intensity = intensity / division * scale;", " intensity = pow(intensity, power);", " gl_FragColor = vec4(glowColor, opacity*(1.0 - intensity));", "}"].join("\n")
    var a = new THREE.Color(this.config.baseConfig.color)
    var n = 1;
    this.material_glow_out = new THREE.ShaderMaterial({
      uniforms: {
        division: {
          type: "f",
          value: Math.sqrt(this.inRadius * this.inRadius - 1e6) / this.inRadius
        },
        coeficient: {
          type: "f",
          value: 1e-4
        },
        power: {
          type: "f",
          value: 5
        },
        scale: {
          type: "f",
          value: .85
        },
        glowColor: {
          type: "c",
          value: a
        },
        opacity: {
          type: "f",
          value: n
        }
      },
      vertexShader: e,
      fragmentShader: t,
      blending: THREE.NormalBlending,
      transparent: !0,
      depthWrite: !1,
      depthTest: !1
    })
    this.material_glow = new THREE.ShaderMaterial({
      uniforms: {
        division: {
          type: "f",
          value: Math.sqrt(this.inRadius * this.inRadius - 1e6) / this.inRadius
        },
        coeficient: {
          type: "f",
          value: 1e-4
        },
        power: {
          type: "f",
          value: 25
        },
        scale: {
          type: "f",
          value: 1
        },
        glowColor: {
          type: "c",
          value: a
        },
        opacity: {
          type: "f",
          value: n
        }
      },
      vertexShader: e,
      fragmentShader: t,
      blending: b.NormalBlending,
      transparent: !0,
      depthWrite: !1,
      depthTest: !1
    })
  }
  showData() {
    var e = new b.SphereBufferGeometry(this.inRadius, 64, 64)
    var t = new b.Mesh(e, this.material_glow_out);
    t.renderOrder = 1
    this.showGroup.add(t);
    var a = new b.Mesh(e, this.material_glow);
    a.renderOrder = 1
    this.showGroup.add(a)
  }
  updateComponent(e) {
    var t = this.config;
    this.config = e.configuration.AtmosphereInner
    if (t.baseConfig.height !== this.config.baseConfig.height) {
      this.inRadius = 1e3 + this.config.baseConfig.height
      this.clearAll()
      this.initMaterial()
      this.showData()
    } else if (t.baseConfig.color !== this.config.baseConfig.color) {
      var a = new b.Color(this.config.baseConfig.color.toLocaleLowerCase())
      if (this.material_glow_out) {
        this.material_glow_out.uniforms.glowColor.value = a
        this.material_glow_out.uniforms.opacity.value = Object(T.rgb)(this.config.baseConfig.color).opacity
      }
      if (this.material_glow) {
        this.material_glow.uniforms.glowColor.value = a
        this.material_glow_out.uniforms.opacity.value = Object(T.rgb)(this.config.baseConfig.color).opacity
      }
    }
  }
  clearAll() {
    this.destroy()
    this.showGroup = new b.Group
    this.otherGroup.add(this.showGroup)
  }
  destroy() {
    this.otherGroup.remove(this.showGroup)
    Object(S.deepDispose)(this.showGroup)
    this.showGroup = null
    this.material_glow_out = null
    this.material_glow = null
  }
}

// 扫描线
class scanning {
  constructor(e, n) {
    this.earthGroup = n.earthGroup
    this.config = e.configuration.scanning
    this.showGroup = new b.Group
    this.earthGroup.add(i.showGroup)
    this.initMaterial()
    this.showData()
  }
  initMaterial() {
    var e = this.config.baseConfig;
    if (this.scaneTexture) this.scaneTexture.dispose()
    if (this.scaneMaterial) this.scaneMaterial.dispose()
    var t = ["varying vec2 vUv;", "void main(){", " vUv = uv;", " gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);", "}"].join("\n")
    var a = ["varying vec2 vUv;", "uniform float time;", "uniform vec3 color;", "uniform float opacity;", "uniform sampler2D scaneTexture;", "void main(){", " vec4 textureColor = texture2D(scaneTexture, vec2(vUv.x, vUv.y + time));", " gl_FragColor = vec4( vec3(textureColor) * color, textureColor.a * opacity);", "}"].join("\n")
    var n = document.createElement("canvas");
    n.style.position = "absolute"
    n.style.top = "0px"
    n.width = 1024
    n.height = 1024
    for (var i = n.getContext("2d"), r = 10; r > 0; r--) {
      i.beginPath()
      i.rect(0, 4 * (10 - r), 1024, 2)
      i.fillStyle = "rgba(255, 255, 255, ".concat(r / 10, ")")
      i.fill()
    }
    this.scaneTexture = new b.Texture(n)
    this.scaneTexture.wrapT = b.RepeatWrapping
    this.scaneTexture.wrapS = b.RepeatWrapping
    this.scaneTexture.needsUpdate = !0
    this.scaneMaterial = new b.ShaderMaterial({
      uniforms: {
        time: {
          type: "f",
          value: 0
        },
        color: {
          type: "c",
          value: (new b.Color).setStyle(e.color.toLocaleLowerCase())
        },
        scaneTexture: {
          value: this.scaneTexture
        },
        opacity: {
          type: "f",
          value: e.opacity
        }
      },
      vertexShader: t,
      fragmentShader: a,
      transparent: !0,
      depthTest: !1,
      blending: b.AdditiveBlending
    })
  }
  showData() {
    this.scaneMesh = new b.Mesh(new b.SphereBufferGeometry(1005, 128, 128), this.scaneMaterial)
    this.scaneMesh.renderOrder = 20
    var e = this.config.baseConfig
    this.scaneMesh.setRotationFromEuler(new b.Euler(0, e.center.lng / 180 * Math.PI, (e.center.lat - 90) / 180 * Math.PI, "XYZ"))
    this.showGroup.add(this.scaneMesh)
  }
  updateComponent(e) {
    var t = this.config.baseConfig;
    this.config = e.configuration.scanning;
    var a = this.config.baseConfig;
    if (t.color !== a.color) {
      this.scaneMaterial.uniforms.color.value = (new b.Color).setStyle(a.color.toLocaleLowerCase())
    }
    if (t.opacity !== a.opacity) {
      this.scaneMaterial.uniforms.opacity.value = a.opacity
    }
    a.center.lng !== t.center.lng || (a.center.lat, t.center.lat)
    this.scaneMesh.setRotationFromEuler(new b.Euler(0, a.center.lng / 180 * Math.PI, (a.center.lat - 90) / 180 * Math.PI, "XYZ"))
  }
  update() {
    var e = this.config.baseConfig;
    this.scaneMaterial && (this.scaneMaterial.uniforms.time.value = (this.scaneMaterial.uniforms.time.value - 5e-4 * e.speed) % 1)
  }
  destroy() {
    this.scaneTexture && this.scaneTexture.dispose()
    this.scaneMaterial && this.scaneMaterial.dispose()
    this.scaneMesh && this.scaneMesh.geometry.dispose()
    this.showGroup.remove(this.scaneMesh)
    this.earthGroup.remove(this.showGroup)
    this.scaneTexture = null
    this.scaneMaterial = null
    this.scaneMesh = null
  }
}

// 六边形标记
class hexagonMark {
  constructor(e, n) {
    this.config = e.configuration.hexagonMark
    this.data = e.data
    this.width = n.width
    this.height = n.height
    this.earthGroup = n.earthGroup
    this.showGroup = new b.Group
    this.outerGroup = new b.Group
    this.showGroup.add(this.outerGroup)
    this.innerGroup = new b.Group
    this.showGroup.add(this.innerGroup)
    this.earthGroup.add(this.showGroup)
    this.initInnerMaterial()
    this.showDataInner()
    this.initOuterMaterial()
    this.showDataOuter()
  }
  initOuterMaterial() {
    var e = this.config.outerConfig;
    this.outerMatLine = new b.LineMaterial({
      color: (new b.Color).setStyle(e.color.toLocaleLowerCase()),
      transparent: !!e.opacity,
      linewidth: e.width,
      dashed: !1
    })
    this.outerMatLine.uniforms.opacity.value = e.opacity
  }
  initInnerMaterial() {
    var e = this.config.innerConfig;
    if (e.show) {
      this.innerMatLine = new b.LineMaterial({
        color: (new b.Color).setStyle(e.color.toLocaleLowerCase()),
        transparent: !!e.opacity,
        linewidth: e.width,
        dashed: !1
      })
      this.innerMatLine.uniforms.opacity.value = e.opacity
    }
  }
  showDataInner() {
    var e = this.config.innerConfig;
    if (e.show) {
      var t
      var a = r(this.data);
      try {
        for (a.s(); !(t = a.n()).done;) {
          var n = t.value
          var i = L(n.lng, n.lat, 1e3)
          var o = new b.CircleGeometry(e.radius, 6);
          o.vertices.shift();
          var s, l = [], u = r(o.vertices);
          try {
            for (u.s(); !(s = u.n()).done;) {
              var c = s.value
              l.push(c.x)
              l.push(c.y)
              l.push(c.z)
            }
          } catch (e) {
            u.e(e)
          } finally {
            u.f()
          }
          l.push(o.vertices[0].x)
          l.push(o.vertices[0].y)
          l.push(o.vertices[0].z)
          var h = new b.Line2((new b.LineGeometry).setPositions(l), this.innerMatLine)
          h.userData = {
            type: "inner"
          }
          h.position.copy(new b.Vector3(i[0], i[1], i[2]))
          h.lookAt(new b.Vector3(0, 0, 0))
          this.innerGroup.add(h)
        }
      } catch (e) {
        a.e(e)
      } finally {
        a.f()
      }
    }
  }
  showDataOuter() {
    var e, t = this.config, a = t.outerConfig, n = (t.innerConfig, r(this.data));
    try {
      for (n.s(); !(e = n.n()).done;) {
        var i = e.value
        var o = L(i.lng, i.lat, 1e3)
        var s = new b.CircleGeometry(a.radius, 6)
        s.vertices.shift()
        var l, u = [], c = r(s.vertices)
        try {
          for (c.s(); !(l = c.n()).done;) {
            var h = l.value
            u.push(h.x)
            u.push(h.y)
            u.push(h.z)
          }
        } catch (e) {
          c.e(e)
        } finally {
          c.f()
        }
        u.push(s.vertices[0].x)
        u.push(s.vertices[0].y)
        u.push(s.vertices[0].z)
        var p = new b.Line2((new b.LineGeometry).setPositions(u), this.outerMatLine);
        p.userData = {
          type: "outer"
        }
        p.position.copy(new b.Vector3(o[0], o[1], o[2]))
        p.lookAt(new b.Vector3(0, 0, 0))
        this.outerGroup.add(p)
      }
    } catch (e) {
      n.e(e)
    } finally {
      n.f()
    }
  }
  updateComponent(e) {
    var t = this.config
    var a = this.data
    this.config = e.configuration.hexagonMark
    this.data = e.data
    var n = this.config
    var i = n.outerConfig
    var r = n.innerConfig
    if (!isEqual(i, t.outerConfig) && this.outerMatLine) {
      this.outerMatLine.color = (new b.Color).setStyle(i.color.toLocaleLowerCase())
      this.outerMatLine.linewidth = i.width
      this.outerMatLine.transparent = !!i.opacity
      this.outerMatLine.uniforms.opacity.value = i.opacity
      if (i.radius !== t.outerConfig.radius) {
        this.destroyOuter()
        this.showDataOuter()
      }
    }
    if (t.innerConfig.show && !r.show) {
      this.destroyInner()
      this.innerMatLine.dispose()
      this.innerMatLine = null
    } else if (!t.innerConfig.show && r.show) {
      this.initInnerMaterial()
      this.showDataInner()
    } else if (t.innerConfig.show && r.show) {
      if (!isEqual(t.innerConfig, r)) {
        this.innerMatLine.color = (new b.Color).setStyle(r.color.toLocaleLowerCase())
        this.innerMatLine.linewidth = r.width
        this.innerMatLine.transparent = !!r.opacity
        this.innerMatLine.uniforms.opacity.value = r.opacity
        if (r.radius !== t.innerConfig.radius) {
          this.destroyInner()
          this.showDataInner()
        }
      }
      if (!isEqual(this.data, a)) {
        this.destroyInner()
        this.destroyOuter()
        this.showDataInner()
        this.showDataOuter()
      }
    }
  }
  update() {
    if (this.outerMatLine) {
      this.outerMatLine.resolution.set(this.width, this.height)
    }
    if (this.innerMatLine) {
      this.innerMatLine.resolution.set(this.width, this.height)
    }
  }
  destroyOuter() {
    if (this.outerGroup) {
      this.outerGroup.traverse(function (e) {
        if ("outer" === e.userData.type && e.geometry) {
          e.geometry.dispose()
          e.geometry = null
        }
      })
      this.outerGroup.children.length = 0
      this.outerGroup.children = []
    }
  }
  destroyInner() {
    if (this.innerGroup) {
      this.innerGroup.traverse(function (e) {
        if ("inner" === e.userData.type && e.geometry) {
          e.geometry.dispose()
          e.geometry = null
        }
      })
      this.innerGroup.children.length = 0
      this.innerGroup.children = []
    }
  }
  destroy() {
    this.destroyOuter()
    this.destroyInner()
    this.earthGroup.remove(this.showGroup)
    this.showGroup = null
    this.innerGroup = null
    this.outerGroup = null
    if (this.innerMatLine) {
      this.outerMatLine.dispose()
    }
    this.outerMatLine = null
    if (this.innerMatLine) {
      this.innerMatLine.dispose()
    }
    this.innerMatLine = null
  }
}

// 柱状图
class barCharts {
  constructor(e, n) {
    this.config = e.configuration.barCharts
    this.data = e.data
    this.earthGroup = n.earthGroup
    this.showGroup = new b.Group
    this.earthGroup.add(i.showGroup)
    this.initMaterial()
    this.showData()
  }
  initMaterial() {
    var e = this.config
    var t = e.colorConfig
    var a = ["#include <logdepthbuf_pars_vertex>", "varying vec2 vUv;", "void main() {", " vUv = uv;", " gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);", " #include <logdepthbuf_vertex>", "}"].join("\n")
    var n = ["#include <logdepthbuf_pars_fragment>", "uniform vec3 bottomColor;", "uniform vec3 topColor;", "uniform float bottomOpacity;", "uniform float topOpacity;", "varying vec2 vUv;", "void main() {", " #include <logdepthbuf_fragment>", " gl_FragColor = vec4(mix(bottomColor, topColor, vUv.y), mix(bottomOpacity, topOpacity, vUv.y));", "}"].join("\n");
    this.barMaterial = new b.ShaderMaterial({
      uniforms: {
        bottomColor: {
          type: "c",
          value: (new b.Color).setStyle(t.bottomColor.toLocaleLowerCase())
        },
        topColor: {
          type: "c",
          value: (new b.Color).setStyle(t.topColor.toLocaleLowerCase())
        },
        bottomOpacity: {
          type: "f",
          value: t.bottomOpacity
        },
        topOpacity: {
          type: "f",
          value: t.topOpacity
        }
      },
      vertexShader: a,
      fragmentShader: n,
      transparent: !0,
      depthTest: !1,
      side: b.DoubleSide
    })
  }
  showData() {
    var e
    var t = this.config
    var a = t.sizeConfig
    var n = max(this.data, e => {
      return e.value
    })
    var i = r(this.data)
    try {
      for (i.s(); !(e = i.n()).done;) {
        var o = e.value
        var s = o.value / n * a.maxHeight
        var l = new b.CylinderBufferGeometry(a.topRadius, a.bottomRadius, s, 16)
        var u = new b.Mesh(l, [this.barMaterial, null])
        var c = new b.Group;
        c.userData = {
          type: "barGroup"
        };
        var h = L(o.lng, o.lat, 1005);
        u.position.z = -s / 2
        u.rotateX(-.5 * Math.PI)
        c.position.x = h[0]
        c.position.y = h[1]
        c.position.z = h[2]
        c.add(u)
        c.lookAt(new b.Vector3(0, 0, 0))
        this.showGroup.add(c)
      }
    } catch (e) {
      i.e(e)
    } finally {
      i.f()
    }
  }
  updateComponent(e) {
    var t = this.config
    var a = this.data;
    this.config = e.configuration.barCharts
    this.data = e.data;
    var n = this.config
    var i = n.sizeConfig
    var r = n.colorConfig;
    Object(w.isEqual)(r, t.colorConfig) || (this.barMaterial.uniforms.bottomColor.value = (new b.Color).setStyle(r.bottomColor.toLocaleLowerCase()),
      this.barMaterial.uniforms.topColor.value = (new b.Color).setStyle(r.topColor.toLocaleLowerCase()),
      this.barMaterial.uniforms.bottomOpacity.value = r.bottomOpacity,
      this.barMaterial.uniforms.topOpacity.value = r.topOpacity),
      Object(w.isEqual)(i, t.sizeConfig) && Object(w.isEqual)(this.data, a) || (this.destroyGeometry(),
        this.showData())
  }
  destroyGeometry() {
    if (this.showGroup) {
      this.showGroup.traverse(function (e) {
        if ("barGroup" === e.userData.type && e.children[0] && e.children[0].geometry) {
          e.children[0].geometry.dispose()
          e.remove(e.children[0])
        }
      })
    }
    this.showGroup.children = []
  }
  destroy() {
    this.destroyGeometry()
    if (this.barMaterial) {
      this.barMaterial.dispose()
      this.barMaterial = null
    }
    this.earthGroup.remove(this.showGroup)
    this.showGroup = null
  }
}

// 真实地球
class simulationEarth {
  constructor(e, n) {
    var i;
    return o(this, a),
      (i = t.call(this, e)).earthGroup = n.earthGroup,
      i.config = e.configuration.simulationEarth,
      i.showGroup = new b.Group,
      i.earthGroup.add(i.showGroup),
      i.initMaterial(),
      i.showData(),
      i
  }
  initMaterial() {
    this.textureLoader || (this.textureLoader = new b.TextureLoader);
    var e = this.config
      , t = e.baseConfig
      , a = e.normalConfig
      , n = e.heightConfig
      , i = e.roughnessConfig
      , r = e.emissiveConfig;
    this.earthMaterial = new b.MeshPhysicalMaterial({
      opacity: t.opacity,
      color: (new b.Color).setStyle(t.color.toLocaleLowerCase()),
      transparent: !0
    }),
      t.texture && (this.earthMaterial.map = this.textureLoader.load(window.appConfig.ASSETS_URL + t.texture)),
      a.support && a.texture && (this.earthMaterial.normalMap = this.textureLoader.load(window.appConfig.ASSETS_URL + a.texture),
        this.earthMaterial.normalScale = new b.Vector2(a.strong, a.strong)),
      n.support && n.texture && (this.earthMaterial.displacementMap = this.textureLoader.load(window.appConfig.ASSETS_URL + n.texture),
        this.earthMaterial.displacementScale = n.strong),
      i.support && i.texture && (this.earthMaterial.metalnessMap = this.textureLoader.load(window.appConfig.ASSETS_URL + i.texture),
        this.earthMaterial.roughness = 1 - i.strong,
        this.earthMaterial.metalness = i.strong),
      r.support && r.texture && (this.earthMaterial.emissiveMap = this.textureLoader.load(window.appConfig.ASSETS_URL + r.texture),
        this.earthMaterial.emissive = (new b.Color).setStyle(r.color.toLocaleLowerCase()),
        this.earthMaterial.emissiveIntensity = r.strong),
      this.earthMaterial.needsUpdate = !0
  }
  showData() {
    this.earth = new b.Mesh(new b.SphereBufferGeometry(1e3, 128, 128), this.earthMaterial),
      this.showGroup.add(this.earth)
  }
  updateComponent(e) {
    var t = this.config
      , a = t.baseConfig
      , n = t.normalConfig
      , i = t.heightConfig
      , r = t.roughnessConfig
      , o = t.emissiveConfig;
    this.config = e.configuration.simulationEarth;
    var s = this.config
      , l = s.baseConfig
      , u = s.normalConfig
      , c = s.heightConfig
      , h = s.roughnessConfig
      , p = s.emissiveConfig;
    Object(w.isEqual)(a, l) || (this.earthMaterial.opacity = l.opacity,
      a.texture !== l.texture && (this.earthMaterial && this.earthMaterial.map && (this.earthMaterial.map.dispose(),
        this.earthMaterial.map = null),
        this.earthMaterial.map = this.textureLoader.load(window.appConfig.ASSETS_URL + l.texture),
        this.earthMaterial.needsUpdate = !0),
      this.earthMaterial.opacity = l.opacity,
      this.earthMaterial.color = (new b.Color).setStyle(l.color.toLocaleLowerCase())),
      Object(w.isEqual)(n, u) || (n.support && !u.support ? this.earthMaterial && this.earthMaterial.normalMap && (this.earthMaterial.normalMap.dispose(),
        this.earthMaterial.normalMap = null,
        this.earthMaterial.needsUpdate = !0) : !n.support && u.support && (this.earthMaterial.normalMap = this.textureLoader.load(window.appConfig.ASSETS_URL + u.texture),
          this.earthMaterial.needsUpdate = !0),
        this.earthMaterial.normalScale = new b.Vector2(u.strong, u.strong)),
      Object(w.isEqual)(i, c) || (i.support && !c.support ? this.earthMaterial && this.earthMaterial.displacementMap && (this.earthMaterial.displacementMap.dispose(),
        this.earthMaterial.displacementMap = null,
        this.earthMaterial.needsUpdate = !0) : !i.support && c.support && (this.earthMaterial.displacementMap = this.textureLoader.load(window.appConfig.ASSETS_URL + c.texture),
          this.earthMaterial.needsUpdate = !0),
        this.earthMaterial.displacementScale = c.strong),
      Object(w.isEqual)(r, h) || (r.support && !h.support ? this.earthMaterial && this.earthMaterial.metalnessMap && (this.earthMaterial.metalnessMap.dispose(),
        this.earthMaterial.metalnessMap = null,
        this.earthMaterial.needsUpdate = !0) : !r.support && h.support && (this.earthMaterial.metalnessMap = this.textureLoader.load(window.appConfig.ASSETS_URL + h.texture),
          this.earthMaterial.needsUpdate = !0),
        this.earthMaterial.roughness = 1 - h.strong,
        this.earthMaterial.metalness = h.strong),
      Object(w.isEqual)(o, p) || (o.support && !p.support ? (this.earthMaterial && this.earthMaterial.emissiveMap && this.earthMaterial.emissiveMap.dispose && (this.earthMaterial.emissiveMap.dispose(),
        this.earthMaterial.emissiveMap = null,
        this.earthMaterial.needsUpdate = !0),
        this.earthMaterial.emissiveIntensity = 1,
        this.earthMaterial.emissive = new b.Color(0)) : p.support && (o.support && o.texture === p.texture || (this.earthMaterial.emissiveMap = this.textureLoader.load(window.appConfig.ASSETS_URL + p.texture),
          this.earthMaterial.needsUpdate = !0),
          this.earthMaterial.emissive = (new b.Color).setStyle(p.color.toLocaleLowerCase()),
          this.earthMaterial.emissiveIntensity = p.strong))
  }
  destroy() {
    this.earthMaterial && (this.earthMaterial.dispose(),
      this.earthMaterial = null),
      this.earthMaterial && this.earthMaterial.map && (this.earthMaterial.map.dispose(),
        this.earthMaterial.map = null),
      this.earthMaterial && this.earthMaterial.normalMap && (this.earthMaterial.normalMap.dispose(),
        this.earthMaterial.normalMap = null),
      this.earthMaterial && this.earthMaterial.displacementMap && (this.earthMaterial.displacementMap.dispose(),
        this.earthMaterial.displacementMap = null),
      this.earthMaterial && this.earthMaterial.metalnessMap && (this.earthMaterial.metalnessMap.dispose(),
        this.earthMaterial.metalnessMap = null),
      this.earthMaterial && this.earthMaterial.emissiveMap && (this.earthMaterial.emissiveMap.dispose(),
        this.earthMaterial.emissiveMap = null),
      this.earth && this.earth.geometry && (this.earth.geometry.dispose(),
        this.earth.geometry = null),
      this.earth = null,
      this.showGroup.remove(this.earth),
      this.earthGroup.remove(this.showGroup),
      this.showGroup = null
  }
}

// 科技感云
class technologyCloud {
  constructor(e, n) {
    var i;
    return o(this, a),
      (i = t.call(this, e)).otherGroup = n.otherGroup,
      i.config = e.configuration.technologyCloud,
      i.showGroup = new b.Group,
      i.otherGroup.add(i.showGroup),
      i.initMaterial(),
      i.showData(),
      i
  }
  initMaterial() {
    var e = ["varying vec2 vUv;", "varying vec3 vVertexWorldPosition;", "varying vec3 vVertexNormal;", "void main(){", " vUv = uv;", " vVertexNormal = normalize(normalMatrix * normal);", " vVertexWorldPosition  = (modelMatrix * vec4(position, 1.0)).xyz;", " gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);", "}"].join("\n")
      , t = ["uniform vec3 color;", "varying vec2 vUv;", "varying vec3 vVertexNormal;", "varying vec3 vVertexWorldPosition;", "uniform sampler2D cloudTexture;", "uniform float  division;", "uniform float  coeficient;", "uniform float  time;", "uniform float  opacity;", "uniform float  xSpeed;", "uniform float  ySpeed;", "uniform float  number;", "void main(){", " float uvY = (vUv.y + time * 0.001 * ySpeed) * number;", " float uvYF = floor(uvY);", " bool show = false;", " if( uvY - uvYF < 0.9 ) {", "  show = true;", " }", " vec3 worldVertexToCamera= cameraPosition - vVertexWorldPosition;", " vec3 viewCameraToVertex = (viewMatrix * vec4(worldVertexToCamera, 0.0)).xyz;", " viewCameraToVertex  = normalize(viewCameraToVertex);", " float intensity   = coeficient + dot(vVertexNormal, viewCameraToVertex);", " if(intensity > division){ discard;}", " intensity = 1.0 - intensity / division;", " if(show) {", "  float offset = 1.0 - abs(uvY - uvYF - 0.45) / 1.2;", "  gl_FragColor = vec4(vec3(texture2D(cloudTexture, vec2(vUv.x + time * 0.002 * xSpeed, vUv.y) )) * vec3(color), pow(offset, 3.0) * intensity * opacity);", " } else {", "  discard;", " }", "}"].join("\n")
      , a = this.config
      , n = a.styleConfig
      , i = a.animationConfig;
    this.cloudTexture = (new b.TextureLoader).load(window.appConfig.ASSETS_URL + n.cloudImage),
      this.cloudTexture.wrapS = this.cloudTexture.wrapT = b.RepeatWrapping,
      this.cloudMaterial = new b.ShaderMaterial({
        uniforms: {
          division: {
            type: "f",
            value: Math.sqrt(n.radius * n.radius - 1e6) / n.radius
          },
          coeficient: {
            type: "f",
            value: .002
          },
          time: {
            type: "f",
            value: 0
          },
          opacity: {
            type: "f",
            value: n.opacity
          },
          xSpeed: {
            type: "f",
            value: i.xSpeed
          },
          ySpeed: {
            type: "f",
            value: i.ySpeed
          },
          number: {
            type: "f",
            value: n.number
          },
          color: {
            type: "c",
            value: (new b.Color).setStyle(n.color.toLocaleLowerCase())
          },
          cloudTexture: {
            type: "f",
            value: this.cloudTexture
          }
        },
        blending: b.AdditiveBlending,
        vertexShader: e,
        fragmentShader: t,
        transparent: !0,
        depthTest: !1
      })
  }
  showData() {
    var e = this.config
      , t = e.styleConfig
      , a = (e.animationConfig,
        new b.SphereBufferGeometry(t.radius, 64, 64));
    this.cloud = new b.Mesh(a, this.cloudMaterial),
      this.showGroup.add(this.cloud)
  }
  update() {
    this.cloudMaterial && (this.cloudMaterial.uniforms.time.value = this.cloudMaterial.uniforms.time.value + 1)
  }
  updateComponent(e) {
    var t = this.config;
    if (this.config = e.configuration.technologyCloud,
      !Object(w.isEqual)(t, this.config)) {
      var a = this.config
        , n = a.styleConfig
        , i = a.animationConfig;
      this.cloudMaterial.uniforms.opacity.value = n.opacity,
        this.cloudMaterial.uniforms.number.value = n.number,
        this.cloudMaterial.uniforms.xSpeed.value = i.xSpeed,
        this.cloudMaterial.uniforms.ySpeed.value = i.ySpeed,
        this.cloudMaterial.uniforms.color.value = (new b.Color).setStyle(n.color.toLocaleLowerCase()),
        n.radius !== t.styleConfig.radius && (this.cloudMaterial.uniforms.division.value = Math.sqrt(n.radius * n.radius - 1e6) / n.radius,
          this.showGroup.remove(this.cloud),
          this.cloud && this.cloud.geometry && (this.cloud.geometry.dispose(),
            this.cloud.geometry = null),
          this.cloud = null,
          this.showData())
    }
  }
  destroy() {
    this.otherGroup.remove(this.showGroup),
      this.showGroup.remove(this.cloud),
      this.cloud && this.cloud.geometry && (this.cloud.geometry.dispose(),
        this.cloud.geometry = null),
      this.cloud = null,
      this.cloudMaterial && (this.cloudMaterial.dispose(),
        this.cloudMaterial = null),
      this.cloudTexture && (this.cloudTexture.dispose(),
        this.cloudTexture = null)
  }
}

// 卫星
class satellite {
  constructor(e, n) {
    var i;
    return o(this, a),
      (i = t.call(this, e)).config = e.configuration.satellite,
      i.otherGroup = n.otherGroup,
      i.showGroup = new b.Group,
      i.otherGroup.add(i.showGroup),
      i.rotateGroup = new b.Group,
      i.showGroup.add(i.rotateGroup),
      i.rotateSpeed = i.config.satelliteConfig.rotateSpeed,
      i.initSatelliteMaterial(),
      i.showSatellite(),
      i.initLineMaterial(),
      i.showLine(),
      i
  }
  initLineMaterial() {
    var e = this.config.orbitalConfig;
    e.show && (this.lineMaterial = new b.LineBasicMaterial({
      color: (new b.Color).setStyle(e.color.toLocaleLowerCase()),
      transparent: !!e.opacity,
      opacity: e.opacity
    }))
  }
  initSatelliteMaterial() {
    var e = this.config.satelliteConfig;
    this.satelliteMaterial = new b.MeshBasicMaterial({
      color: (new b.Color).setStyle(e.color.toLocaleLowerCase()),
      transparent: !!e.opacity,
      opacity: e.opacity,
      wireframe: !0
    })
  }
  showSatellite() {
    var e = this
      , t = this.config
      , a = t.orbitalConfig
      , n = t.satelliteConfig
      , i = new b.OBJLoader;
    n.model && i.load(window.appConfig.ASSETS_URL + n.model, (function (t) {
      e.satellite = t,
        e.satellite.traverse((function (t) {
          t.isMesh && (t.material = e.satelliteMaterial)
        }
        )),
        e.satellite.scale.x = e.satellite.scale.y = e.satellite.scale.z = n.scale,
        e.satellite.setRotationFromEuler(new b.Euler(n.rotateX / 180 * Math.PI, n.rotateY / 180 * Math.PI, n.rotateZ / 180 * Math.PI, "XYZ")),
        e.satellite.position.x = a.radius,
        e.rotateGroup.add(e.satellite)
    }
    ))
  }
  showLine() {
    var e = this.config.orbitalConfig;
    if (e.show) {
      for (var t = [], a = 0; a <= 128; a++)
        t.push(Math.cos(a / 64 * Math.PI) * e.radius, Math.sin(a / 64 * Math.PI) * e.radius, 0);
      var n = new b.BufferGeometry;
      n.addAttribute("position", new b.Float32BufferAttribute(t, 3)),
        this.satelliteLine = new b.Line(n, this.lineMaterial),
        this.showGroup.add(this.satelliteLine)
    }
    this.showGroup.setRotationFromEuler(new b.Euler(e.rotateX / 180 * Math.PI, e.rotateY / 180 * Math.PI, e.rotateZ / 180 * Math.PI, "XYZ"))
  }
  update() {
    this.rotateSpeed && this.rotateGroup && this.rotateGroup.rotateZ(8e-4 * this.rotateSpeed)
  }
  updateComponent(e) {
    var t = this.config
      , a = t.orbitalConfig
      , n = t.satelliteConfig;
    this.config = e.configuration.satellite;
    var i = this.config
      , r = i.orbitalConfig
      , o = i.satelliteConfig;
    Object(w.isEqual)(a, r) || (a.show && !r.show ? (this.destroyLine(),
      this.lineMaterial && (this.lineMaterial.dispose(),
        this.lineMaterial = null)) : a.show && r.show ? (this.lineMaterial.color = (new b.Color).setStyle(r.color.toLocaleLowerCase()),
          this.lineMaterial.opacity = r.opacity,
          a.radius !== r.radius ? (this.destroyLine(),
            this.showLine(),
            this.satellite.position.x = r.radius) : this.showGroup.setRotationFromEuler(new b.Euler(r.rotateX / 180 * Math.PI, r.rotateY / 180 * Math.PI, r.rotateZ / 180 * Math.PI, "XYZ"))) : !a.show && r.show && (this.initLineMaterial(),
              this.showLine())),
      Object(w.isEqual)(n, o) || (this.satelliteMaterial.color = (new b.Color).setStyle(o.color.toLocaleLowerCase()),
        this.satelliteMaterial.opacity = r.opacity,
        this.rotateSpeed = o.rotateSpeed,
        n.model !== o.model ? (this.destroySatellite(),
          this.showSatellite()) : (this.satellite.scale.x = this.satellite.scale.y = this.satellite.scale.z = o.scale,
            this.satellite.setRotationFromEuler(new b.Euler(o.rotateX / 180 * Math.PI, o.rotateY / 180 * Math.PI, o.rotateZ / 180 * Math.PI, "XYZ"))))
  }
  destroySatellite() {
    if (this.rotateGroup.remove(this.satellite),
      this.satellite) {
      var e, t = r(this.satellite.children);
      try {
        for (t.s(); !(e = t.n()).done;) {
          var a = e.value;
          a && a.geometry && a.geometry.dispose()
        }
      } catch (e) {
        t.e(e)
      } finally {
        t.f()
      }
      this.satellite = null
    }
  }
  destroyLine() {
    this.showGroup.remove(this.satelliteLine),
      this.satelliteLine && this.satelliteLine.geometry.dispose()
  }
  destroy() {
    this.destroySatellite(),
      this.destroyLine(),
      this.showGroup.remove(this.rotateGroup),
      this.rotateGroup = null,
      this.rotateSpeed = null,
      this.lineMaterial && (this.lineMaterial.dispose(),
        this.lineMaterial = null),
      this.satelliteMaterial && (this.satelliteMaterial.dispose(),
        this.satelliteMaterial = null)
  }
}

// 飞线
class flyLine {
  ta = ["#include <logdepthbuf_pars_vertex>", "varying vec2 vUv;", "void main(){", " vUv = uv;", " gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);", " #include <logdepthbuf_vertex>", "}"].join("\n")
  aa = ["#include <logdepthbuf_pars_fragment>", "varying vec2 vUv;", "uniform float time;", "uniform float offset;", "uniform bool lineShow;", "uniform vec3 lineColor;", "uniform float lineOpacity;", "uniform vec3 startColor;", "uniform float startOpacity;", "uniform vec3 endColor;", "uniform float endOpacity;", "uniform float lineLength;", "void main(){", " #include <logdepthbuf_fragment>", " float start = time * 0.0005 + offset;", " start = fract(start) * (1.0 + lineLength) - lineLength;", " float end = start + lineLength;", " float offset = end - vUv.x;", " if(offset < 0.0 || offset > lineLength) {", "  if(lineShow) {", "   gl_FragColor = vec4(lineColor, lineOpacity);", "  } else {", "   discard;", "  }", " } else {", "  float intensity = 1.0;", "  intensity = 1.0 - abs(offset / lineLength);", "  gl_FragColor = vec4(vec3(mix(endColor, startColor, intensity)), mix(endOpacity, startOpacity, intensity));", " }", "}"].join("\n")
  constructor(e, n) {
    var i;
    return o(this, a),
      (i = t.call(this, e)).selectAction = function (e, t) {
        if (e && e.componentId && e.componentId === i.id) {
          var a = t.id
            , n = t.onRelative
            , r = t.emit
            , o = i.interaction.callback;
          if (n) {
            var s = Object.values(o)
              , l = {};
            s.map((function (t) {
              l[t.target] = e.userData[t.origin] || null
            }
            )),
              n(a, l)
          }
          r && r("click", [B({}, e.userData)], i.id)
        }
      }
      ,
      i.earthGroup = n.earthGroup,
      i.id = e.id,
      i.config = e.configuration.flyLine,
      i.interaction = e.configuration.interaction,
      i.showGroup = new b.Group,
      i.labelGroup = new b.Group,
      i.circlePlane = new b.Group,
      i.earthGroup.add(i.showGroup, i.labelGroup, i.circlePlane),
      i.data = e.data,
      i.timers = [],
      i.keyframes = [],
      i.showData(),
      i
  }
  showData() {
    var e = this.config
      , t = e.styleConfig
      , a = e.animationConfig
      , n = e.bubbleConfig;
    if (this.data && this.data.length > 0) {
      var i, o = r(this.data);
      try {
        for (o.s(); !(i = o.n()).done;) {
          var s = i.value
            , l = a.startRandom ? Math.random() * Math.random() * 10 : 0
            , u = new b.ShaderMaterial({
              uniforms: {
                time: {
                  type: "f",
                  value: 0
                },
                offset: {
                  type: "f",
                  value: l
                },
                lineShow: {
                  value: !!t.lineConfig.opacity && t.lineConfig.show
                },
                lineColor: {
                  value: (new b.Color).setStyle(t.lineConfig.color.toLocaleLowerCase())
                },
                lineOpacity: {
                  value: t.lineConfig.opacity
                },
                startColor: {
                  value: (new b.Color).setStyle(t.startColor.toLocaleLowerCase())
                },
                startOpacity: {
                  value: t.startOpacity
                },
                endColor: {
                  value: (new b.Color).setStyle(t.endColor.toLocaleLowerCase())
                },
                endOpacity: {
                  value: t.endOpacity
                },
                lineLength: {
                  value: t.lineLength
                }
              },
              vertexShader: ta,
              fragmentShader: aa,
              transparent: !0
            })
            , c = s.startLng
            , h = s.startLat
            , p = s.endLng
            , d = s.endLat
            , m = s.endText
            , f = c < 0 ? c + 360 : c
            , g = p < 0 ? p + 360 : p
            , v = new b.Vector2(Number(f), Number(h))
            , y = new b.Vector2(Number(g), Number(d))
            , _ = v.clone().lerp(y, .35)
            , w = v.clone().lerp(y, .65)
            , M = N(f, h, 1e3)
            , x = N(g, d, 1e3)
            , C = (new b.Vector3).addVectors(M, x).multiplyScalar(.5)
            , S = M.distanceTo(x)
            , L = C.distanceTo(new b.Vector3(0, 0, 0))
            , A = 3 * S / 10
            , G = (4e3 + 4 * t.lineHeight - L) / 3
            , D = Math.sqrt(A * A + G * G)
            , k = N(_.x, _.y, D)
            , P = N(w.x, w.y, D)
            , R = new b.CubicBezierCurve3(M, k, P, x)
            , O = new b.TubeBufferGeometry(R, 50, t.lineWidth, 3, !1)
            , I = new b.Mesh(O, u);
          if (I.userData = B({}, s),
            t.headIcon.show) {
            I.userData.curveLine = R;
            var j = this.initFlyLineIcon(M.clone(), x.clone(), t.headIcon.url, t.headIcon.iconWidth, t.headIcon.iconHeight);
            I.add(j),
              I.userData.icon = j
          }
          if (I.renderOrder = 10,
            I.interactive = !0,
            I.componentId = this.id,
            this.showGroup.add(I),
            m && n.show) {
            var F = n.textConfig
              , U = n.backConfig
              , z = U.width
              , V = U.height
              , q = U.positionHeight
              , H = U.scale
              , Y = U.basePosition
              , $ = z / V
              , X = E(m, F, U)
              , W = new b.SpriteMaterial({
                transparent: !0
              });
            W.map = new b.Texture(X),
              W.map.anisotropy = 16,
              W.map.needsUpdate = !0;
            var K = new b.Sprite(W)
              , Z = N(g, d, 1e3 + q);
            K.position.copy(Z),
              K.center = new b.Vector2(Y.x, Y.y),
              K.scale.set(H, H / $, 1),
              this.labelGroup.add(K)
          }
          if (t.circlePlaneConfig.show) {
            var J = N(g, d, 1e3)
              , Q = new b.PlaneGeometry(t.circlePlaneConfig.circleRadius, t.circlePlaneConfig.circleRadius, 10, 10)
              , ee = new b.ShaderMaterial({
                uniforms: {
                  time: {
                    type: "f",
                    value: 0
                  },
                  opacity: {
                    value: Object(T.rgb)(t.circlePlaneConfig.circleColor.toLocaleLowerCase()).opacity
                  },
                  color: {
                    value: (new b.Color).setStyle(t.circlePlaneConfig.circleColor.toLocaleLowerCase())
                  }
                },
                vertexShader: "\n  varying vec2 vUv;\n  void main(){\n    vUv = uv;\n    gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n  }\n",
                fragmentShader: "\n  varying vec2 vUv;\n  uniform float time;\n  uniform float opacity;\n  uniform vec3 color;\n  void main(){\n    float w = 0.4;\n    float r = distance(vec2(0.5), vUv);\n    float calR = 0.5*time;\n    if(r > calR-0.2 && r < calR) {\n        if(r > 0.5 - 0.2) {\n          discard;\n        }else {\n          float a = (r - (calR-0.2))/0.2;\n          gl_FragColor = vec4(color, a * opacity);\n        }\n    }else {\n      discard;\n    }\n  }\n",
                transparent: !0,
                side: b.BackSide,
                depthWrite: !1,
                depthTest: !1
              })
              , te = new b.Mesh(Q, ee);
            te.position.copy(J),
              te.lookAt(0, 0, 0),
              this.adjustVertor(Q, 1e3),
              I.add(te),
              I.userData.circlePlane = te
          }
        }
      } catch (e) {
        o.e(e)
      } finally {
        o.f()
      }
    }
  }
  adjustVertor(e, t) {
    e.vertices.forEach((function (e) {
      var a = e.length()
        , n = Math.sqrt(a * a + t * t)
        , i = t * (n - t) / n;
      e.z = i
    }
    )),
      e.verticesNeedUpdate = !0
  }
  initFlyLineIcon(e, t, a, n, i) {
    !this.textureLoader && (this.textureLoader = new b.TextureLoader);
    var r = new b.Group
      , o = new b.PlaneBufferGeometry(n, i)
      , s = new b.MeshBasicMaterial({
        map: this.textureLoader.load(window.appConfig.ASSETS_URL + a),
        side: b.DoubleSide,
        transparent: !0,
        depthWrite: !1
      })
      , l = new b.Mesh(o, s);
    return l.rotation.y = Math.PI,
      l.rotation.x = Math.PI / 2,
      r.userData.plane = l,
      r.up = e.add(t).divideScalar(2).normalize(),
      r.add(l),
      r
  }
  getSupportObjects() {
    return this.showGroup
  }
  updateComponent(e) {
    var t = this.config
      , a = this.data;
    this.config = e.configuration.flyLine,
      this.data = e.data,
      Object(w.isEqual)(t, this.config) && Object(w.isEqual)(a, this.data) || (this.destroyAnimate(),
        this.destroyLine(),
        this.destroyLabel(),
        this.showData())
  }
  destroyLine() {
    var e, t = r(this.showGroup.children);
    try {
      for (t.s(); !(e = t.n()).done;) {
        var a = e.value;
        if (a && a.geometry && a.geometry.dispose(),
          a.geometry = null,
          a && a.material && a.material.dispose(),
          a.material = null,
          a.userData.icon) {
          var n = a.userData.icon.userData.plane;
          n.geometry.dispose(),
            n.material.dispose(),
            a.userData.icon.remove(n),
            a.remove(a.userData.icon),
            a.userData.icon = null
        }
        if (a.userData.circlePlane) {
          var i = a.userData.circlePlane;
          i.geometry.dispose(),
            i.material.dispose(),
            a.remove(i),
            a.userData.circlePlane = null
        }
      }
    } catch (e) {
      t.e(e)
    } finally {
      t.f()
    }
    this.showGroup.children.length = 0,
      this.showGroup.children = []
  }
  destroyLabel() {
    this.labelGroup.children.map((function (e) {
      e.material && (e.material.map = null,
        e.material.dispose()),
        e.geometry && e.geometry.dispose(),
        e.material = null,
        e.geometry = null
    }
    )),
      this.labelGroup.children = []
  }
  destroyAnimate() {
    this.timers && (this.timers.forEach((function (e) {
      return clearTimeout(e)
    }
    )),
      this.timers = []),
      this.keyframes && (this.keyframes.forEach((function (e) {
        return e.stop()
      }
      )),
        this.keyframes = [])
  }
  update() {
    if (this.config.animationConfig.speed) {
      var e, t = r(this.showGroup.children);
      try {
        for (t.s(); !(e = t.n()).done;) {
          var a = e.value;
          if (a && a.material) {
            var n = a.material.uniforms.offset.value
              , i = a.material.uniforms.lineLength.value
              , o = a.material.uniforms.time.value + this.config.animationConfig.speed;
            a.material.uniforms.time.value = o;
            var s = 5e-4 * o + n;
            if (s = (s - Math.floor(s)) * (1 + i),
              a.userData.circlePlane) {
              var l = a.userData.circlePlane.material
                , u = s;
              u > 1 && u < 1 + i && (l.uniforms.time.value = (u - 1) / i)
            }
            if (this.config.styleConfig.headIcon.show) {
              var c = a.userData.curveLine.getPointAt(s, new b.Vector3);
              a.userData.icon.position.copy(c),
                a.userData.icon.userData.plane.material.opacity = s > .8 ? (1 - s) / .2 : s < .2 ? s / .2 : 1;
              var h = a.userData.curveLine.getPointAt(s + .02, new b.Vector3);
              a.userData.icon.lookAt(h.applyMatrix4(this.showGroup.matrixWorld))
            }
          }
        }
      } catch (e) {
        t.e(e)
      } finally {
        t.f()
      }
    }
  }
  destroy() {
    this.destroyAnimate(),
      this.destroyLabel(),
      this.destroyLine(),
      this.earthGroup.remove(this.showGroup),
      this.showGroup = null,
      this.data = null,
      this.config = null
  }
}

// 点标记
class pointMark {
  constructor(e, n) {
    var i;
    return o(this, a),
      (i = t.call(this, e)).config = e.configuration.pointMark,
      i.data = e.data,
      i.earthGroup = n.earthGroup,
      i.showGroup = new b.Group,
      i.earthGroup.add(i.showGroup),
      i.initMaterial(),
      i.showData(),
      i
  }
  initMaterial() {
    var e = this.config.baseConfig
      , t = e.mix;
    this.textureLoader || (this.textureLoader = new b.TextureLoader),
      this.shaderMaterial && (this.shaderMaterial.dispose(),
        this.ShaderMaterial = null);
    var a = ["varying vec2 vUv;", "void main() {", "  vUv = uv;", "  gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4( position, 1.0 );", "}"].join("\n")
      , n = ["varying vec2 vUv;", "uniform vec3 color;", "uniform sampler2D texture;", "void main() {", "  vec4 textureColor = texture2D( texture, vUv );", "  if ( textureColor.a < 0.0001 ) discard;", "  gl_FragColor = vec4(color, (textureColor.r + textureColor.g + textureColor.b) / 3.0);", "}"].join("\n");
    this.shaderMaterial = new b.ShaderMaterial({
      uniforms: {
        color: {
          value: (new b.Color).setStyle(t.color.toLocaleLowerCase())
        },
        texture: {
          value: this.textureLoader.load(window.appConfig.ASSETS_URL + e.pointImage)
        }
      },
      side: b.BackSide,
      vertexShader: a,
      fragmentShader: t.show ? n : "\n      uniform sampler2D texture;\n      varying vec2 vUv;\n\n      void main( void ) {\n        vec4 tColor = texture2D(texture, vUv);\n        gl_FragColor = tColor;      \n      }\n    ",
      depthTest: !1,
      transparent: !0
    })
  }
  showData() {
    var e = this.config.baseConfig;
    this.destroyPoint();
    var t, a = r(this.data);
    try {
      for (a.s(); !(t = a.n()).done;) {
        var n = t.value
          , i = L(n.lng, n.lat, 1001)
          , o = new b.Mesh(new b.PlaneBufferGeometry(e.size, e.size, 1, 1), this.shaderMaterial);
        o.position.set(i[0], i[1], i[2]),
          o.lookAt(new b.Vector3(0, 0, 0)),
          this.showGroup.add(o)
      }
    } catch (e) {
      a.e(e)
    } finally {
      a.f()
    }
  }
  updateComponent(e) {
    var t = this.config.baseConfig
      , a = this.data;
    this.config = e.configuration.pointMark,
      this.data = e.data;
    var n = this.config.baseConfig;
    if (!Object(w.isEqual)(t, n)) {
      this.initMaterial();
      var i, o = r(this.showGroup.children);
      try {
        for (o.s(); !(i = o.n()).done;) {
          i.value.material = this.shaderMaterial
        }
      } catch (e) {
        o.e(e)
      } finally {
        o.f()
      }
    }
    Object(w.isEqual)(a, this.data) && t.size === n.size || (this.destroyPoint(),
      this.showData())
  }
  destroyPoint() {
    var e, t = r(this.showGroup.children);
    try {
      for (t.s(); !(e = t.n()).done;) {
        var a = e.value;
        a.geometry && a.geometry.dispose(),
          a.geometry = null
      }
    } catch (e) {
      t.e(e)
    } finally {
      t.f()
    }
    this.showGroup.children.length = 0,
      this.showGroup.children = []
  }
  destroy() {
    this.data = null,
      this.textureLoader = null,
      this.texture && (this.texture.dispose(),
        this.texture = null),
      this.shaderMaterial && (this.shaderMaterial.dispose(),
        this.ShaderMaterial = null),
      this.destroyPoint(),
      this.earthGroup.remove(this.showGroup),
      this.showGroup = null
  }
}

// 名称标牌
class nameBubble {
  constructor(e, n) {
    var i;
    return o(this, a),
      (i = t.call(this, e)).earthGroup = n.earthGroup,
      i.earthCamera = n.earthCamera,
      i.config = e.configuration.nameBubble,
      i.data = e.data,
      i.showGroup = new b.Group,
      i.earthGroup.add(i.showGroup),
      i.showData(),
      i
  }
  showData() {
    var e,
      t = this.config.bubbleConfig,
      a = t.renderOrder,
      n = (t.width, t.height),
      i = t.scale,
      o = t.basePosition,
      s = t.positionHeight,
      l = r(this.data);
    try {
      for (l.s(); !(e = l.n()).done;) {
        var u = e.value
        c = this.drawCanvas(u.name)
        h = c.drawingCanvas
        p = c.calWidth / n
        d = new b.SpriteMaterial({
          transparent: !0,
          depthTest: !1
        });
        d.map = new b.Texture(h)
        d.map.anisotropy = 16
        d.map.needsUpdate = !0;
        var m = L(u.lng, u.lat, 1e3 + s)
        f = new b.Sprite(d);
        f.center = new b.Vector2(o.x, o.y)
        f.position.set(m[0], m[1], m[2])
        f.scale.set(i * p, i, 1)
        f.renderOrder = a
        this.showGroup.add(f)
      }
    } catch (e) {
      l.e(e)
    } finally {
      l.f()
    }
  }
  drawCanvas(e) {
    var t = this.config
      , a = t.bubbleConfig
      , n = t.nameConfig
      , i = a.width
      , r = a.height
      , o = (a.scale,
        a.topDecorate)
      , s = document.createElement("canvas");
    s.setAttribute("width", i),
      s.setAttribute("height", r);
    var l = s.getContext("2d");
    l.font = "normal ".concat(n.fontSize, "px ").concat(n.fontFamily),
      l.fillStyle = n.color,
      l.textAlign = "center",
      l.textBaseline = "middle";
    var u = i * (l.measureText(e).width / i) + 64;
    s.setAttribute("width", u),
      l.fillStyle = a.color,
      l.fillRect(0, 0, u, r);
    var c = 0;
    return o.show && (l.fillStyle = o.color,
      l.fillRect(0, 0, u, o.height),
      c = o.height),
      l.font = "normal ".concat(n.fontSize, "px ").concat(n.fontFamily),
      l.fillStyle = n.color,
      l.textAlign = "center",
      l.textBaseline = "middle",
      l.fillText(e, u / 2, c + (r - c) / 2),
    {
      drawingCanvas: s,
      calWidth: u
    }
  }
  update() {
    var e = this;
    this.showGroup.children.map((function (t) {
      var a = t.position.clone();
      a.applyMatrix4(e.showGroup.matrixWorld),
        a.distanceTo(e.earthCamera.position) > e.earthCamera.position.length() ? t.visible = !1 : t.visible = !0
    }
    ))
  }
  updateComponent(e) {
    var t = this.config
      , a = this.data;
    this.config = e.configuration.nameBubble,
      this.data = e.data,
      Object(w.isEqual)(t, this.config) && Object(w.isEqual)(a, this.data) || (this.destroyBubble(),
        this.showData())
  }
  destroyBubble() {
    var e, t = r(this.showGroup.children);
    try {
      for (t.s(); !(e = t.n()).done;) {
        var a = e.value;
        a.material && (a.material.map && a.material.map.dispose(),
          a.material.dispose()),
          a = null
      }
    } catch (e) {
      t.e(e)
    } finally {
      t.f()
    }
    this.showGroup.children.length = 0,
      this.showGroup.children = []
  }
  destroy() {
    this.destroyBubble(),
      this.earthGroup.remove(this.showGroup),
      this.showGroup = null,
      this.data = null,
      this.config = null
  }
}

// 场景管理器
class scenarioManager {
  constructor(e, n) {
    var i;
    return o(this, a),
      (i = t.call(this, e)).earthGroup = n.earthGroup,
      i.scene = n.scene,
      i.earthCamera = n.earthCamera,
      i.mapContainer = n.mapContainer,
      i.setCurrentScenarioManager = n.setCurrentScenarioManager,
      i.clearScenarioManagerAnimation = n.clearScenarioManagerAnimation,
      i.config = e.configuration.scenarioManager,
      i.data = e.data,
      i.showGroup = new b.Group,
      i.earthGroup.add(i.showGroup),
      i.currentIndex = 0,
      i.animationId = null,
      i.setTimeoutId = void 0,
      i.startAnimationAction = i.startAnimationAction.bind(u(i)),
      i.config.baseConfig.defaultOpen && i.startAnimationAction(),
      i.button = document.createElement("div"),
      i.button.id = e.id + "_button",
      i.button.style.position = "absolute",
      i.button.style.top = "0px",
      i.button.style.left = "0px",
      i.button.style.width = "0px",
      i.button.style.height = "0px",
      i.mapContainer.appendChild(i.button),
      i.button.addEventListener("click", i.startAnimationAction),
      i.earthRotateSwitch = !0,
      i
  }
  flyAction(e) {
    var t = this
      , a = (this.config.baseConfig,
        this.data[e]);
    a && (this.setTimeoutId = setTimeout((function () {
      var n, i, r, o, s, l = (n = t.earthCamera.position.x,
        i = t.earthCamera.position.y,
        r = t.earthCamera.position.z,
        o = Math.sqrt(n * n + i * i + r * r),
        s = Math.asin(i / o),
      {
        lng: (r >= 0 ? -Math.acos(n / Math.sqrt(o * o - i * i)) : Math.acos(n / Math.sqrt(o * o - i * i))) / Math.PI * 180,
        lat: s / Math.PI * 180,
        distance: o
      });
      t.animationId = Wt({
        from: {
          lng: l.lng,
          lat: l.lat,
          distance: l.distance,
          leftRight: t.earthCamera.userData.leftRight ? t.earthCamera.userData.leftRight : 0,
          bottomTop: t.earthCamera.userData.bottomTop ? t.earthCamera.userData.bottomTop : 0
        },
        to: {
          lng: a.position.lng,
          lat: a.position.lat,
          distance: a.position.distance,
          leftRight: a.sceneOffset.leftRight,
          bottomTop: a.sceneOffset.bottomTop
        },
        duration: a.duration
      }).start({
        update: function (e) {
          var a = N(e.lng, e.lat, e.distance).applyQuaternion(t.earthGroup.quaternion);
          t.earthCamera.position.x = a.x,
            t.earthCamera.position.y = a.y,
            t.earthCamera.position.z = a.z;
          var n = new b.Vector2(a.x, a.z).normalize();
          n = new b.Vector2(n.y, -n.x),
            t.scene.position.x = n.x * e.leftRight,
            t.scene.position.z = n.y * e.leftRight,
            t.scene.position.y = e.bottomTop,
            t.earthCamera.userData = {
              leftRight: e.leftRight,
              bottomTop: e.bottomTop
            }
        },
        complete: function () {
          t.flyAction("circulation" === t.config.baseConfig.playPattern && e + 1 >= t.data.length ? 0 : e + 1)
        }
      })
    }
    ), a.delay),
      this.earthRotateSwitch = void 0 === a.earthRotateSwitch ? this.earthRotateSwitch : !!a.earthRotateSwitch),
      this.setCurrentScenarioManager(this)
  }
  startAnimationAction() {
    this.stopAnimationAction(),
      this.flyAction(0)
  }
  startAnimationActionByCallback(e) {
    var t = this.config.activateConfig
      , a = t.valueName
      , n = t.callbackValue;
    e && void 0 !== a && void 0 !== n && e[a] == n && this.startAnimationAction()
  }
  stopAnimationAction() {
    this.setTimeoutId && (clearTimeout(this.setTimeoutId),
      this.setTimeoutId = void 0),
      this.animationId && (this.animationId.stop(),
        this.animationId = void 0)
  }
  getEarthRotateState() {
    return this.earthRotateSwitch
  }
  updateComponent(e) {
    var t = this.config
      , a = this.data;
    this.config = e.configuration.scenarioManager,
      this.data = e.data,
      Object(w.isEqual)(t, this.config) && Object(w.isEqual)(a, this.data) || this.config.baseConfig.defaultOpen && this.startAnimationAction()
  }
  destroy() {
    this.stopAnimationAction(),
      this.button && (this.button.removeEventListener("click", this.startAnimationAction),
        this.mapContainer.removeChild(this.button),
        this.button = void 0),
      this.data = null,
      this.config = null
  }
}

// 装饰星星
class movingStars {
  constructor(e, n) {
    var i;
    return o(this, a),
      (i = t.call(this, e)).config = e.configuration.movingStars,
      i.data = e.data,
      i.otherGroup = n.otherGroup,
      i.earthCamera = n.earthCamera,
      i.showGroup = new b.Group,
      i.otherGroup.add(i.showGroup),
      i.initMaterial(),
      i.showData(),
      i
  }
  initMaterial() {
    var e = ["attribute float size;", "void main() {", "  vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);", "  gl_PointSize = size * (300.0 / -mvPosition.z);", "  gl_Position = projectionMatrix * mvPosition;", "}"].join("\n")
      , t = ["uniform vec3 color;", "uniform float opacity;", "void main() {", "  gl_FragColor = vec4( color, opacity );", "}"].join("\n");
    this.material = new b.ShaderMaterial({
      uniforms: {
        color: {
          value: (new b.Color).setStyle(this.config.baseConfig.color.toLocaleLowerCase())
        },
        opacity: {
          value: this.config.baseConfig.opacity
        }
      },
      vertexShader: e,
      fragmentShader: t,
      transparent: !0
    })
  }
  showData() {
    for (var e = this.config.baseConfig, t = (e.color,
      e.maxSize), a = e.minSize, n = e.number, i = e.encircleInRadius, r = e.encircleOutRadius, o = Math.floor(n / 2), s = n - o, l = new Float32Array(s), u = new Float32Array(3 * s), c = new Float32Array(o), h = new Float32Array(3 * o), p = 0; p < s;) {
      var d = this._getRandomPosition(i, r);
      u[3 * p + 0] = d.x,
        u[3 * p + 1] = d.y,
        u[3 * p + 2] = d.z,
        l[p] = a + (t - a) * Math.random(),
        p++
    }
    var m = new b.BufferGeometry;
    for (m.addAttribute("position", new b.BufferAttribute(u, 3)),
      m.addAttribute("size", new b.BufferAttribute(l, 1)),
      this.particlesRight = new b.Points(m, this.material),
      this.showGroup.add(this.particlesRight),
      p = 0; p < o;) {
      var f = this._getRandomPosition(i, r);
      h[3 * p + 0] = f.x,
        h[3 * p + 1] = f.y,
        h[3 * p + 2] = f.z,
        c[p] = a + (t - a) * Math.random(),
        p++
    }
    var g = new b.BufferGeometry;
    g.addAttribute("position", new b.BufferAttribute(h, 3)),
      g.addAttribute("size", new b.BufferAttribute(c, 1)),
      this.particlesLeft = new b.Points(g, this.material),
      this.showGroup.add(this.particlesLeft)
  }
  _getRandomPosition(e, t) {
    var a = new b.Vector3(Math.random() - .5, Math.random() - .5, Math.random() - .5);
    return a.normalize(),
      a.multiplyScalar(e + (t - e) * Math.random())
  }
  updateComponent(e) {
    var t = this.config.baseConfig
      , a = this.data;
    this.config = e.configuration.movingStars;
    var n = this.config.baseConfig;
    this.data = e.data,
      Object(w.isEqual)(a, this.data) && t.encircleInRadius === n.encircleInRadius && t.encircleOutRadius === n.encircleOutRadius && t.maxSize === n.maxSize && t.minSize === n.minSize && t.number === n.number || (this.destroyPoint(),
        this.showData()),
      t.color === n.color && t.opacity === n.opacity || (this.material.uniforms.color.value = (new b.Color).setStyle(n.color.toLocaleLowerCase()),
        this.material.uniforms.opacity.value = n.opacity)
  }
  update() {
    var e = this.config.baseConfig.rotateSpeed;
    e && this.particlesRight && this.particlesRight.rotateY(1e-5 * e),
      e && this.particlesLeft && this.particlesLeft.rotateY(-1e-5 * e)
  }
  destroyPoint() {
    this.particlesRight && this.particlesRight.geometry && (this.showGroup.remove(this.particlesRight),
      this.particlesRight.geometry.dispose(),
      this.particlesRight = null),
      this.particlesLeft && this.particlesLeft.geometry && (this.showGroup.remove(this.particlesLeft),
        this.particlesLeft.geometry.dispose(),
        this.particlesLeft = null)
  }
  destroy() {
    this.destroyPoint(),
      this.otherGroup.remove(this.showGroup),
      this.showGroup = null,
      this.material && (this.material.dispose(),
        this.material = null),
      this.data = null,
      this.config = null
  }
}

// 环境光
class ambientLight {
  constructor(e, n) {
    this.scene = n.scene
    this.config = e.configuration.ambientLight
    this.showData()
    return this
  }
  showData() {
    var e = this.config.baseConfig;
    this.ambientLight = new b.AmbientLight(new b.Color(e.color.toLocaleLowerCase()), e.intensity)
    this.scene.add(this.ambientLight)
  }
  updateComponent(e) {
    var t = this.config;
    this.config = e.configuration.ambientLight
    if (!isEqual(t.baseConfig, this.config.baseConfig)) {
      if (this.ambientLight) {
        this.ambientLight.color = new b.Color(this.config.baseConfig.color.toLocaleLowerCase())
        this.ambientLight.intensity = this.config.baseConfig.intensity
      }
    }
  }
  destroy() {
    this.scene.remove(this.ambientLight)
    this.ambientLight = null
    this.config = null
  }
}

// 方向光
class directionalLight {
  constructor(e, n) {
    this.scene = n.scene
    this.config = e.configuration.directionalLight
    this.showData()
    return this
  }
  showData() {
    var config = this.config.baseConfig
    const color = new THREE.Color(e.color)
    this.directionalLight = new THREE.DirectionalLight(color, config.intensity)
    this.directionalLight.position.x = config.position.x
    this.directionalLight.position.y = config.position.y
    this.directionalLight.position.z = config.position.z
    this.scene.add(this.directionalLight)
  }
  updateComponent(e) {
    var t = this.config
    this.config = e.configuration.directionalLight
    if (!isEqual(t.baseConfig, this.config.baseConfig)) {
      if (this.directionalLight) {
        this.directionalLight.color = new b.Color(this.config.baseConfig.color)
        this.directionalLight.intensity = this.config.baseConfig.intensity
        this.directionalLight.position.x = this.config.baseConfig.position.x
        this.directionalLight.position.y = this.config.baseConfig.position.y
        this.directionalLight.position.z = this.config.baseConfig.position.z
      }
    }
  }
  destroy() {
    this.scene.remove(this.directionalLight)
    this.directionalLight = null
    this.config = null
  }
}

class bubblingPoints {
  constructor(e, n) {
    var i;
    return o(this, a),
      i = t.call(this, e),
      console.log(e),
      i.config = e.configuration.bubblingPoints,
      i.data = e.data,
      i.earthGroup = n.earthGroup,
      i.showGroup = new b.Group,
      i.earthGroup.add(i.showGroup),
      i.showData(),
      i
  }
  showData() {
    var e = new b.SphereBufferGeometry(1000.1, 128, 128)
      , t = document.createElement("video");
    t.muted = !0,
      t.preload = "auto",
      t.loop = !0,
      t.autoPlay = !0,
      t.controls = !0,
      t.crossOrigin = "anonymous",
      t.addEventListener("canplay", (function (e) {
        e.target.play()
      }
      )),
      t.src = window.appConfig.ASSETS_URL + this.config.video;
    var a = new b.VideoTexture(t);
    this.mesh = new b.Mesh(e, new b.MeshBasicMaterial({
      map: a,
      blending: b.AdditiveBlending,
      transparent: !0
    })),
      this.earthGroup.add(this.mesh)
  }
  updateComponent(e) { }
  destroy() {
    this.earthGroup.remove(this.mesh),
      this.mesh && (this.mesh.geometry.dispose,
        this.mesh.material.map.dispose(),
        this.mesh.material.dispose()),
      this.mesh = null,
      this.data = null,
      this.config = null
  }
}

// 表面线
class surfaceLine {
  ha = ["#include <logdepthbuf_pars_vertex>", "varying vec2 vUv;", "void main(){", " vUv = uv;", " gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);", " #include <logdepthbuf_vertex>", "}"].join("\n")
  pa = ["#include <logdepthbuf_pars_fragment>", "varying vec2 vUv;", "uniform float time;", "uniform float count;", "uniform sampler2D texture;", "void main(){", " #include <logdepthbuf_fragment>", "  gl_FragColor = texture2D( texture, vec2(fract(vUv.x*count + time), fract(vUv.y*2.0 - 0.2)) );", "}"].join("\n")
  constructor(e, n) {
    var i;
    return o(this, a),
      (i = t.call(this, e)).selectAction = function (e, t) {
        if (e && e.componentId && e.componentId === i.id) {
          var a = t.id
            , n = t.onRelative
            , r = t.emit
            , o = i.interaction.callback;
          if (n) {
            var s = Object.values(o)
              , l = {};
            s.map((function (t) {
              l[t.target] = e.userData[t.origin] || null
            }
            )),
              n(a, l)
          }
          r && r("click", [B({}, e.userData)], i.id)
        }
      }
      ,
      i.earthGroup = n.earthGroup,
      i.config = e.configuration.surfaceLine,
      i.showGroup = new b.Group,
      i.id = e.id,
      i.interaction = e.configuration.interaction,
      i.earthGroup.add(i.showGroup),
      i.data = e.data,
      i.showData(),
      i
  }
  getSupportObjects() {
    return this.showGroup
  }
  showData() {
    var e = this
      , t = this.config.styleConfig;
    if (this.data && this.data.length > 0 && t.lineTextureConfig.show && t.lineTextureConfig.lineTexture) {
      var a = window.appConfig.ASSETS_URL + t.lineTextureConfig.lineTexture;
      !this.textureLoader && (this.textureLoader = new b.TextureLoader);
      for (var n = 0; n < this.data.length; n++) {
        var i = this.data[n].geometry && "LineString" === this.data[n].geometry.type && this.data[n].geometry.coordinates;
        i && i.length >= 2 && function () {
          for (var n = [], r = 0; r < i.length; r++)
            if (0 == r) {
              var o = i[r]
                , s = N(o[0], o[1], 1e3);
              n.push(s)
            } else if (r > 0)
              for (var l = i[r], u = i[r - 1], c = N(l[0], l[1], 1e3), h = N(u[0], u[1], 1e3), p = e.calSurfacePoints(h, c), d = 0; d < p.length; d++)
                n.push(p[d]);
          var m = new b.CatmullRomCurve3(n)
            , f = new b.TubeBufferGeometry(m, 5 * n.length, t.lineTextureConfig.lineWidth, 8, !1)
            , g = new b.ShaderMaterial({
              uniforms: {
                time: {
                  value: 0
                },
                count: {
                  value: m.getLength() / t.lineTextureConfig.repeatLength
                },
                texture: {
                  value: e.textureLoader.load(a)
                }
              },
              vertexShader: ha,
              fragmentShader: pa,
              transparent: !0
            })
            , v = new b.Mesh(f, g);
          if (v.userData.curveLine = m,
            v.interactive = !0,
            v.componentId = e.id,
            e.showGroup.add(v),
            "image" == t.iconType) {
            if (t.lineIconConfig.show && t.lineIconConfig.lineIcon) {
              var y = window.appConfig.ASSETS_URL + t.lineIconConfig.lineIcon
                , _ = e.initSurfaceLineIcon(y, t.lineIconConfig.iconWidth, t.lineIconConfig.iconHeight);
              _.renderOrder = 1,
                v.userData.icon = _,
                v.add(_)
            }
          } else if (t.modelIconConfig.show && t.lineIconConfig.lineIcon) {
            var w = window.appConfig.ASSETS_URL + t.modelIconConfig.modelURL;
            e.initSurfaceLineModel(w, (function (e) {
              e.renderOrder = 1,
                v.userData.icon = e,
                v.add(e)
            }
            ))
          }
        }()
      }
    }
  }
  initSurfaceLineModel(e, t) {
    !this.loader && (this.loader = new b.GLTFLoader),
      this.loader.load(e, (function (e) {
        var a = e.scene;
        a.scale.set(.5, .5, .5),
          a.traverse((function (e) {
            e.material && (e.material.transparent = !0)
          }
          )),
          t(a)
      }
      ))
  }
  initSurfaceLineIcon(e, t, a) {
    !this.textureLoader && (this.textureLoader = new b.TextureLoader);
    var n = new b.Sprite(new b.SpriteMaterial({
      map: this.textureLoader.load(e),
      transparent: !0,
      depthTest: !1
    }));
    return n.scale.set(t, a, 1),
      n
  }
  calSurfacePoints(e, t) {
    for (var a = Math.PI / 128, n = e.angleTo(t), i = n < a ? 0 : n / a, r = 1 / i, o = 0, s = [], l = 1; l < i; l++) {
      var u = e.clone().lerp(t.clone(), o).normalize();
      u.normalize(),
        u.multiplyScalar(1e3),
        s.push(u),
        o += r
    }
    return s.push(t),
      s
  }
  updateComponent(e) {
    var t = this.config
      , a = this.data;
    this.config = e.configuration.surfaceLine,
      this.data = e.data,
      Object(w.isEqual)(t, this.config) && Object(w.isEqual)(a, this.data) || (this.disposeSurfaceLines(t.styleConfig.iconType),
        this.showData())
  }
  disposeSurfaceLines(e) {
    for (; this.showGroup.children.length > 0;) {
      var t = this.showGroup.children[0]
        , a = t.userData.icon;
      a && ("image" === e ? (a.geometry.dispose(),
        a.material.dispose(),
        t.remove(a)) : (Object(S.deepDispose)(a),
          t.remove(a))),
        t.geometry.dispose(),
        t.material.dispose(),
        this.showGroup.remove(t)
    }
  }
  update() {
    var e = this;
    this.showGroup.children.map((function (t) {
      if (t.material.uniforms.time.value += (2 * Number(e.config.animationConfig.isOpposite) - 1) * e.config.animationConfig.speed / 1e3,
        e.config.styleConfig.lineIconConfig.show && t.userData.icon) {
        var a = e.config.animationConfig.ratio
          , n = t.material.uniforms.count.value
          , i = t.material.uniforms.time.value / n
          , r = i - Math.floor(i)
          , o = t.userData.curveLine.getPointAt(1 - r, new b.Vector3)
          , s = t.userData.icon;
        if (s)
          if (s.position.copy(o),
            "image" === e.config.styleConfig.iconType)
            s.material.opacity = r > 1 - a ? (1 - r) / a : r < a ? r / a : 1;
          else {
            var l = e.config.styleConfig.modelIconConfig
              , u = l.modelScale
              , c = l.rotateStep;
            if (s.up = o.clone().applyMatrix4(e.showGroup.matrixWorld.clone()).normalize(),
              1 - r + c > 0 && 1 - r + c < 1) {
              var h = t.userData.curveLine.getPointAt(1 - r + c, new b.Vector3);
              s.lookAt(h.applyMatrix4(e.showGroup.matrixWorld.clone()))
            }
            if (r > 1 - a) {
              var p = (1 - r) / a;
              s.scale.set(p * u, p * u, p * u),
                s.traverse((function (e) {
                  e.material && (e.material.opacity = p)
                }
                ))
            } else if (r < a) {
              var d = r / a;
              s.scale.set(d * u, d * u, d * u),
                s.traverse((function (e) {
                  e.material && (e.material.opacity = d)
                }
                ))
            } else {
              s.scale.set(1 * u, 1 * u, 1 * u),
                s.traverse((function (e) {
                  e.material && (e.material.opacity = 1)
                }
                ))
            }
          }
      }
    }
    ))
  }
  destroy() {
    this.disposeSurfaceLines(),
      this.earthGroup.remove(this.showGroup),
      this.showGroup = null,
      this.data = null,
      this.config = null
  }
}

// 火车
class train {
  constructor(e, n) {
    var i;
    return o(this, a),
      (i = t.call(this, e)).earthGroup = n.earthGroup,
      i.config = e.configuration.train,
      i.showGroup = new b.Group,
      i.earthGroup.add(i.showGroup),
      i.data = e.data,
      i.tarinMove = i.tarinMove.bind(u(i)),
      i.loadModel(),
      i
  }
  loadModel() {
    var e = this;
    !this.loader && (this.loader = new b.GLTFLoader);
    var t = window.appConfig.ASSETS_URL + "components/static-image/earth3DNew/train3.gltf";
    this.loader.load(t, (function (t) {
      e.model = t.scene;
      var a = e.config.modelConfig.scale
        , n = e.model.children[3]
        , i = e.model.children[0]
        , r = e.model.children[1]
        , o = e.model.children[2];
      n.scale.set(a, a, a),
        i.scale.set(a, a, a),
        r.scale.set(a, a, a),
        o.scale.set(a, a, a),
        e.showGroup.add(n, i, r, o),
        e.showGroup.userData.head = n,
        e.showGroup.userData.carriage1 = i,
        e.showGroup.userData.carriage2 = r,
        e.showGroup.userData.carriage3 = o,
        e.showGroup.traverse((function (e) {
          e.material && (e.material.transparent = !0)
        }
        )),
        e.timer = e.tarinMove(n, i, r, o)
    }
    ))
  }
  tarinMove(e, t, a, i) {
    var r = this
      , o = new b.CatmullRomCurve3(this.data.map((function (e) {
        return N(e.lng, e.lat, 1e3)
      }
      )))
      , s = this.config.offsetConfig
      , l = s.offset1
      , u = s.offset2
      , c = s.offset3;
    return Wt({
      from: {
        t: 0
      },
      to: {
        t: .99
      },
      ease: n.easeInOut,
      loop: 1 / 0,
      duration: 1e3 * this.config.animationConfig.animateTime
    }).start({
      update: function (n) {
        e.position.copy(o.getPointAt(n.t, new b.Vector3)),
          e.lookAt(o.getPointAt(Math.min(1, n.t + .01), new b.Vector3)),
          e.up = e.position.clone().normalize(),
          t.position.copy(o.getPointAt(Math.max(n.t - l, 0), new b.Vector3)),
          t.lookAt(o.getPointAt(Math.max(n.t - l + .002, 0), 0, new b.Vector3)),
          t.up = t.position.clone().normalize(),
          a.position.copy(o.getPointAt(Math.max(n.t - u, 0), new b.Vector3)),
          a.lookAt(o.getPointAt(Math.max(n.t - u + .002, 0), 0, new b.Vector3)),
          a.up = a.position.clone().normalize(),
          i.position.copy(o.getPointAt(Math.max(n.t - c, 0), new b.Vector3)),
          i.lookAt(o.getPointAt(Math.max(n.t - c + .002, 0), 0, new b.Vector3)),
          i.up = i.position.clone().normalize(),
          r.showGroup.traverse((function (e) {
            e.material && (n.t < r.config.animationConfig.ratio ? e.material.opacity = n.t / r.config.animationConfig.ratio : n.t > r.config.animationConfig.ratio ? e.material.opacity = 1 - (n.t - (1 - r.config.animationConfig.ratio)) / r.config.animationConfig.ratio : e.material.opacity = 1)
          }
          ))
      }
    })
  }
  updateComponent(e) {
    var t = this.config
      , a = this.data;
    if (this.config = e.configuration.train,
      this.data = e.data,
      Object(w.isEqual)(a, this.data) || (this.timer && this.timer.stop(),
        this.showGroup && this.disposeGrroup(),
        this.loadModel()),
      !Object(w.isEqual)(t, this.config)) {
      this.timer && this.timer.stop();
      var n = this.showGroup.userData
        , i = n.head
        , r = n.carriage1
        , o = n.carriage2
        , s = n.carriage3;
      this.timer = this.tarinMove(i, r, o, s);
      var l = this.config.modelConfig.scale;
      i.scale.set(l, l, l),
        r.scale.set(l, l, l),
        o.scale.set(l, l, l),
        s.scale.set(l, l, l)
    }
  }
  update() { }
  disposeGrroup() {
    for (; this.showGroup.children.length > 0;) {
      var e = this.showGroup.children[0];
      Object(S.deepDispose)(e),
        this.showGroup.remove(e)
    }
  }
  destroy() {
    this.timer && this.timer.stop(),
      this.showGroup && this.disposeGrroup(),
      this.earthGroup.remove(this.showGroup),
      this.showGroup = null,
      this.data = null,
      this.config = null
  }
}

// 云层
class AtmoCloud {
  constructor(e, n) {
    var i;
    return o(this, a),
      (i = t.call(this, e)).config = e.configuration.AtmoCloud,
      i.otherGroup = n.otherGroup,
      i.showGroup = new b.Group,
      i.otherGroup.add(i.showGroup),
      i.textureLoader = new b.TextureLoader,
      i.initMaterial(),
      i.createCloud(),
      i
  }
  initMaterial() {
    this.cloudMaterial && (this.cloudMaterial.map && this.cloudMaterial.map.dispose(),
      this.cloudMaterial.dispose()),
      this.texture = this.textureLoader.load(window.appConfig.ASSETS_URL + this.config.baseConfig.texture),
      this.texture.wrapS = b.RepeatWrapping,
      this.texture.wrapT = b.RepeatWrapping,
      this.cloudMaterial = new b.MeshPhongMaterial({
        map: this.texture,
        transparent: !0,
        opacity: this.config.baseConfig.opacity,
        depthWrite: !1
      })
  }
  createCloud() {
    var e = new b.SphereBufferGeometry(1e3 + this.config.baseConfig.height, 64, 64);
    this.cloud = new b.Mesh(e, this.cloudMaterial),
      this.showGroup.add(this.cloud)
  }
  updateComponent(e) {
    var t = this.config;
    this.config = e.configuration.AtmoCloud,
      t.baseConfig.height !== this.config.baseConfig.height ? (this.disposeCloud(),
        this.initMaterial(),
        this.createCloud()) : t.baseConfig.texture !== this.config.baseConfig.texture ? (this.disposeCloud(),
          this.config.baseConfig.texture && (this.initMaterial(),
            this.createCloud())) : this.cloudMaterial && (this.cloudMaterial.opacity = this.config.baseConfig.opacity)
  }
  update() {
    if (this.texture) {
      var e = this.config.baseConfig.speed;
      this.texture.offset.x -= e,
        this.texture.offset.y += e
    }
  }
  disposeCloud() {
    this.cloud && (this.showGroup.remove(this.cloud),
      this.cloud.geometry.dispose(),
      this.cloud.material.map.dispose(),
      this.cloud.material.dispose())
  }
  destroy() {
    this.disposeCloud(),
      this.otherGroup.remove(this.showGroup),
      this.showGroup = null,
      this.cloud = null,
      this.texture = null,
      this.cloudMaterial = null
  }
}

// 区域热力
class canvasPolygon {
  constructor(e, n) {
    var i;
    return o(this, a),
      (i = t.call(this, e)).earthGroup = n.earthGroup,
      i.config = e.configuration.canvasPolygon,
      i.data = e.data,
      i.showGroup = new b.Group,
      i.earthGroup.add(i.showGroup),
      i.width = 8192,
      i.height = i.width / 2,
      i.canvasDom = null,
      i.initMaterial(),
      i.showData(),
      i
  }
  initMaterial() {
    this.textureLoader || (this.textureLoader = new b.TextureLoader);
    this.config.baseConfig;
    this.canvasDom || (this.canvasDom = document.createElement("canvas"),
      this.canvasDom.setAttribute("width", this.width),
      this.canvasDom.setAttribute("height", this.height)),
      this.earthMaterial = new b.MeshBasicMaterial({
        map: new b.Texture(this.canvasDom),
        transparent: !0
      })
  }
  showData() {
    this.getData(),
      this.earth = new b.Mesh(new b.SphereBufferGeometry(1001, 128, 128), this.earthMaterial),
      this.showGroup.add(this.earth)
  }
  getData() {
    var e = this;
    fetch(window.appConfig.ASSETS_URL + this.config.baseConfig.mapData).then((function (e) {
      return e.json()
    }
    )).then((function (t) {
      e.mapData = t,
        e.drawCanvas()
    }
    ))
  }
  formateDataAction() {
    var e = this;
    this.formateData = {},
      this.data.forEach((function (t) {
        t.name && !isNaN(Number(t.value)) && (e.formateData[t.name] = Number(t.value))
      }
      ))
  }
  formateDataConfigAction() {
    var e = this
      , t = this.config.dataConfig;
    this.formateDataConfig = [],
      Object.keys(t).map((function (a) {
        var n = t[a]
          , i = n.min
          , r = n.max
          , o = n.color;
        isNaN(i) || isNaN(r) || !o || e.formateDataConfig.push(n)
      }
      ))
  }
  getStyleByValue(e) {
    var t = this.config.baseConfig.defaultFill.fillColor;
    if (isNaN(e))
      return t;
    for (var a = 0; a < this.formateDataConfig.length; a++) {
      var n = this.formateDataConfig[a];
      if (e >= n.min && e <= n.max) {
        t = n.color;
        break
      }
    }
    return t
  }
  drawCanvas() {
    var e = this;
    this.formateDataAction(),
      this.formateDataConfigAction();
    var t = this.config.baseConfig.defaultStroke
      , a = this.canvasDom.getContext("2d");
    a.clearRect(0, 0, this.width, this.height),
      this.mapData && this.mapData.features.forEach((function (n) {
        var i = n.geometry
          , r = i.coordinates
          , o = i.type
          , s = n.properties.name;
        a.strokeStyle = t.strokeStyle,
          a.lineWidth = t.lineWidth;
        var l = e.getStyleByValue(e.formateData[s]);
        a.fillStyle = l,
          "MultiPolygon" === o ? r.forEach((function (t) {
            t.forEach((function (t) {
              a.beginPath(),
                t.forEach((function (t) {
                  var n = (t[0] + 180) / 360 * e.width
                    , i = (90 - t[1]) / 180 * e.height;
                  a.lineTo(n, i)
                }
                )),
                a.stroke()
            }
            ))
          }
          )) : "Polygon" === o && r.forEach((function (t) {
            a.beginPath(),
              t.forEach((function (t) {
                var n = (t[0] + 180) / 360 * e.width
                  , i = (90 - t[1]) / 180 * e.height;
                a.lineTo(n, i)
              }
              )),
              a.stroke()
          }
          )),
          "MultiPolygon" === o ? r.forEach((function (t) {
            t.forEach((function (t) {
              a.beginPath(),
                t.forEach((function (t) {
                  var n = (t[0] + 180) / 360 * e.width
                    , i = (90 - t[1]) / 180 * e.height;
                  a.lineTo(n, i)
                }
                )),
                a.fill()
            }
            ))
          }
          )) : "Polygon" === o && r.forEach((function (t) {
            a.beginPath(),
              t.forEach((function (t) {
                var n = (t[0] + 180) / 360 * e.width
                  , i = (90 - t[1]) / 180 * e.height;
                a.lineTo(n, i)
              }
              )),
              a.fill()
          }
          ))
      }
      )),
      this.earthMaterial.map.needsUpdate = !0,
      this.earthMaterial.needsUpdate = !0
  }
  updateComponent(e) {
    var t = this.config
      , a = t.baseConfig
      , n = t.dataConfig
      , i = this.data;
    this.config = e.configuration.canvasPolygon;
    var r = this.config
      , o = r.baseConfig
      , s = r.dataConfig;
    this.data = e.data,
      Object(w.isEqual)(a.mapData, o.mapData) ? Object(w.isEqual)(a.defaultStroke, o.defaultStroke) && Object(w.isEqual)(a.defaultFill, o.defaultFill) && Object(w.isEqual)(n, s) && Object(w.isEqual)(i, this.data) || this.drawCanvas() : this.getData()
  }
  destroy() {
    this.earthMaterial && (this.earthMaterial.dispose(),
      this.earthMaterial = null),
      this.earthMaterial && this.earthMaterial.map && (this.earthMaterial.map.dispose(),
        this.earthMaterial.map = null),
      this.earth && this.earth.geometry && (this.earth.geometry.dispose(),
        this.earth.geometry = null),
      this.earth = null,
      this.showGroup.remove(this.earth),
      this.earthGroup.remove(this.showGroup),
      this.showGroup = null,
      this.config = null,
      this.data = null,
      this.formateDataConfig = null,
      this.formateData = null,
      this.width = null,
      this.height = null,
      this.mapData = null
  }
}

// iframe标牌
class iframeBubble {
  constructor(e, n) {
    var i;
    return o(this, a),
      (i = t.call(this, e)).earthGroup = n.earthGroup,
      i.earthCamera = n.earthCamera,
      i.mapContainer = n.mapContainer,
      i.scene = n.scene,
      i.centerX = n.width / 2,
      i.centerY = n.height / 2,
      i.config = e.configuration.iframeBubble,
      i.showData = e.data[0],
      i.showDataAction(),
      i
  }
  initIframeDom(e) {
    this.iframeDom = document.createElement("iframe"),
      this.iframeDom.style.position = "absolute",
      this.iframeDom.style.width = e.width + "px",
      this.iframeDom.style.height = e.height + "px",
      this.iframeDom.style.pointerEvents = "none",
      this.iframeDom.style.border = "none"
  }
  showDataAction() {
    this.showData && this.showData.url && this.showData.width && this.showData.height && (this.initIframeDom(this.showData),
      this.updateBubblePostion(this.showData),
      this.iframeDom.src = this.showData.url,
      this.mapContainer.appendChild(this.iframeDom))
  }
  updateBubblePostion(e) {
    var t = N(e.lng, e.lat, 1e3)
      , a = (t = (t = t.applyQuaternion(this.earthGroup.quaternion)).applyQuaternion(this.scene.quaternion)).project(this.earthCamera)
      , n = e.offsetX ? e.offsetX : 0
      , i = e.offsetY ? e.offsetY : 0
      , r = Math.round(this.centerX * a.x + this.centerX)
      , o = Math.round(-this.centerY * a.y + this.centerY);
    this.iframeDom.style.left = r + n + "px",
      this.iframeDom.style.top = o + i + "px"
  }
  update() {
    this.iframeDom && this.showData && this.showData.url && this.showData.width && this.showData.height && this.updateBubblePostion(this.showData)
  }
  updateComponent(e) {
    var t = this.showData;
    this.showData = e.data[0],
      console.log(!(this.showData && this.showData.url && this.showData.width && this.showData.height)),
      this.showData && this.showData.url && this.showData.width && this.showData.height || !this.iframeDom ? Object(w.isEqual)(t, this.showData) || (this.iframeDom ? (t.width === this.showData.width && t.height === this.showData.height || (this.iframeDom.style.width = this.showData.width + "px",
        this.iframeDom.style.height = this.showData.height + "px"),
        t.url !== this.showData.url && (this.iframeDom.src = this.showData.url)) : this.showDataAction()) : (this.mapContainer.removeChild(this.iframeDom),
          this.iframeDom = null)
  }
  destroy() {
    this.iframeDom && this.mapContainer.removeChild(this.iframeDom),
      this.iframeDom = null,
      this.config = null,
      this.data = null
  }
}
